简体   繁体   English

向Liferay JSON API提交REST请求时发生未知错误

[英]Unknown error when submit a REST request to Liferay json API

I'm writing an script in Python to automatically update the structures in my Liferay portal and I want to do it via the json REST API. 我正在用Python编写脚本,以自动更新Liferay门户中的结构,我想通过JSON REST API进行操作。

I make a request to get an structure (method getStructure), and it worked. 我请求获取一个结构(方法getStructure),并且它起作用了。

But when I try to do an structure update in the portal it shows me the following error: 但是,当我尝试在门户中进行结构更新时,会显示以下错误:

ValueError: Content-Length should be specified for iterable data  
of type class 'dict' {'serviceContext': "{'prueba'}", 'serviceClassName':
'com.liferay.portlet.journal.service.JournalStructureServiceUtil', 'name': 'FOO',
'xsd': '... THE XSD OBTAINED VIA JSON ...', 'serviceParameters':
'[groupId,structureId,parentStructureId,name,description,xsd,serviceContext]',
'description': 'FOO Structure', 'serviceMethodName': 'updateStructure',
'groupId': '10133'}

What I'm doing is the next: 我在做什么是下一个:

urllib.request.Request(url = URL, data = data_update, headers = headers)

URL is http://localhost:8080/tunnel-web/secure/json 网址为http:// localhost:8080 / tunnel-web / secure / json
The headers are configured with basic authentication (it works, it is tested with the getStructure method). 标头使用基本身份验证进行配置(它可以正常工作,并使用getStructure方法进行了测试)。
Data is: 数据是:

data_update = {
"serviceClassName" : "com.liferay.portlet.journal.service.JournalStructureServiceUtil",
"serviceMethodName" : "updateStructure",
"serviceParameters" : "[groupId,structureId,parentStructureId,name,description,xsd,serviceContext]",
"groupId" : 10133,
"name" : FOO,
"description" : FOO Structure,
"xsd" : ... THE XSD OBTAINED VIA JSON ...,
"serviceContext" : "{}" }

Does anybody know the solution? 有人知道解决方案吗? Have I to specify the length for the dictionary and how? 我需要指定字典的长度吗? Or this is a bug? 还是这是一个错误?

This might help you. 可能对您有帮助。 It seems it is python's bug. 看来这是python的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将包含json的原始正文提交到REST API - submit raw body containing json to REST api 有没有其他方法可以在Django中请求JSON REST API? - Is there an alternative way to request JSON REST API in django? 使用 API GET 请求以及 JSON 和 Python 时收到错误 - Error received when using an API GET request, with JSON and Python 使用带有 json 和 python 的 API 获取请求时收到错误 - Error received when using an API get request with json and python 尝试提交时表单请求 flask 错误 - Form request flask error when trying to submit LendingClub Rest API提交订单响应500内部服务器错误 - LendingClub Rest API Submit Order reponse 500 Internal Server Error TensorFlow 服务 REST API - JSON 解析错误 - TensorFlow Serving REST API - JSON Parse Error 为什么通过python请求调用rest api时出现500 Internal Server Error? - Why am I getting 500 Internal Server Error when calling post rest api via python request? 在Flask中构建REST API尝试发出POST请求时出现400错误 - Building a REST API in Flask getting a 400 error when trying to make a POST request 怎么修<response [400]>向 Python 中的 Bitget Futures Rest API 发出请求时出错?</response> - How to fix <Response [400]> error when making a request to the Bitget Futures Rest API in Python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM