向Liferay json API提交REST请求时出现未知错误

时间:2011-11-18 09:44:36

标签: python json rest xsd liferay

我正在用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" : "{}" }

有人知道解决方案吗?我是否要指定字典的长度以及如何?或者这是一个错误?

1 个答案:

答案 0 :(得分:1)

This可能会对您有所帮助。这似乎是python的错误。