向 Liferay json API 提交 REST 请求时出现未知错误
我正在用 Python 编写一个脚本来自动更新 Liferay 门户中的结构,并且我想通过 json REST API 来完成此操作。
我请求获取一个结构(方法 getStructure),并且它有效。
但是,当我尝试在门户中进行结构更新时,它显示以下错误:
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'}
我正在做的是下一个:
urllib.request.Request(url = URL, data = data_update, headers = headers)
URL 是
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" : "{}" }
有人知道解决方案吗?我必须指定字典的长度以及如何指定吗?或者这是一个错误?
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.
I make a request to get an structure (method getStructure), and it worked.
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
The headers are configured with basic authentication (it works, it is tested with the getStructure method).
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能对您有帮助。看来这是python的bug。
This might help you. It seems it is python's bug.