向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)
网址是 http://localhost:8080/tunnel-web/secure/json
请求头已经设置了基本的身份验证(这个部分是有效的,我用getStructure方法测试过)。
数据是:
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" : "{}" }
有没有人知道解决办法?我需要为字典指定长度吗?如果需要的话该怎么做?还是说这是一个bug?
1 个回答
1
这个链接可能对你有帮助。看起来这是Python的一个bug。