Unknown error when submit a REST request to Liferay json API
        Posted  
        
            by 
                r.rodriguez
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by r.rodriguez
        
        
        
        Published on 2011-11-18T09:44:36Z
        Indexed on 
            2011/11/18
            9:51 UTC
        
        
        Read the original article
        Hit count: 461
        
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?
© Stack Overflow or respective owner