【发布时间】:2011-11-18 09:44:36
【问题描述】:
我正在用 Python 编写一个脚本来自动更新我的 Liferay 门户中的结构,我想通过 json REST API 来完成。
我请求获取一个结构(方法 getStructure),它成功了。
但是当我尝试在门户中进行结构更新时,它会显示以下错误:
ValueError: Content-Length 应该为类型类'dict' {'serviceContext': "{'prueba'}", 'serviceClassName':'com.liferay.portlet.journal.service 的可迭代数据指定.JournalStructureServiceUtil', 'name': 'FOO',
'xsd': '...通过 JSON 获得的 XSD ...', 'serviceParameters':
'[groupId,structureId,parentStructureId,name, description,xsd,serviceContext]',
'description': 'FOO 结构', 'serviceMethodName': 'updateStructure',
'groupId': '10133'}
接下来要做的是:
urllib.request.Request(url = URL, data = data_update, headers = headers)
网址是http://localhost:8080/tunnel-web/secure/json
标头配置了基本身份验证(它有效,已使用 getStructure 方法进行测试)。
数据是:
“serviceClassName”:“com.liferay.portlet.journal.service.JournalStructureServiceUtil”,
“serviceMethodName”:“updateStructure”,
“serviceParameters”:“[groupId,structureId,parentStructureId, name,description,xsd,serviceContext]",
"groupId" : 10133,
"name" : FOO,
"description" : FOO 结构,
"xsd" : ... XSD通过 JSON 获得 ...,
"serviceContext" : "{}" }
有人知道解决办法吗?我是否必须指定字典的长度以及如何指定?或者这是一个错误?
【问题讨论】:
标签: python json rest xsd liferay