【问题标题】:Unknown error when submit a REST request to Liferay json API向 Liferay json API 提交 REST 请求时出现未知错误
【发布时间】: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 方法进行测试)。
数据是:

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 结构,
"xsd" : ... XSD通过 JSON 获得 ...,
"serviceContext" : "{}" }

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

【问题讨论】:

    标签: python json rest xsd liferay


    【解决方案1】:

    This 可能会对您有所帮助。好像是python的bug。

    【讨论】:

    • 是的,我用 Python 2.7 尝试过,它发出了请求。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-12
    • 1970-01-01
    • 1970-01-01
    • 2021-04-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多