简体   繁体   中英

Creating App using Parse.com REST API in Python

Trying to create an app using Parse.com REST API in Python, I have used the code detailed in the REST guide and adjusted a couple of things based on previous errors I received, however this one I'm really not sure where to go with:

import json,httplib
connection = httplib.HTTPSConnection('api.parse.com', 443)
connection.connect()
connection.request('POST', '/1/apps', json.dumps("{'appName':'my new app','clientClassCreationEnabled':false}"), {
       "X-Parse-Email": "EMAIL",
       "X-Parse-Password": "PASSWORD",
       "Content-Type": "application/json"
       })
result = json.loads(connection.getresponse().read())
print(result)

I'm getting the following error:

{u'code': 256, u'error': u'App name is required to create a new app'}

Does anybody know a solution for this or where I might be going wrong? I haven't been able to find anything.

Cheers

you should pass dict to json.dumps , not a string

import json,httplib
connection = httplib.HTTPSConnection('api.parse.com', 443)
connection.connect()
connection.request('POST', '/1/apps', json.dumps({'appName':'my new app','clientClassCreationEnabled':False}), {
   "X-Parse-Email": "EMAIL",
   "X-Parse-Password": "PASSWORD",
   "Content-Type": "application/json"
   })
result = json.loads(connection.getresponse().read())
print(result)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM