python - How to make a connection to Parse via requests instead of httplib -



python - How to make a connection to Parse via requests instead of httplib -

i'm trying connect custom endpoint i've set on parse cloud code. in docs show how create connection:

import json,httplib connection = httplib.httpsconnection('api.parse.com', 443) connection.connect() connection.request('post', '/1/functions/userdata', json.dumps({ "userid": "1234" }), { "x-parse-application-id": "####", "x-parse-rest-api-key": "####", "content-type": "application/json" }) result = json.loads(connection.getresponse().read()) print result

this work great.

i'm trying write requests continually 404:

import json, requests parse_hostname = 'https://api.parse.com:443' parse_app_id = '####' parse_rest_api_key = '####' endpoint = '/1/function/userdata/' headers = {"x-parse-application-id": parse_app_id, "x-parse-rest-api-key": "parse_rest_api_key", "content-type": "application/json"} payload = {'userid': '1234'} r = requests.post(parse_hostname + endpoint, data=json.dumps(payload), headers=headers) print r.json

which prints out:

<bound method response.json of <response [404]>>

i sense i'm missing obvious. sorry ignorance. how accomplish same result first requests?

url misspelling in sec example. have

/1/function/userdata/

must be

/1/functions/userdata

python python-2.7 parse.com python-requests

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -