Skip to content

Instantly share code, notes, and snippets.

/curl.txt Secret

Created February 13, 2015 05:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3aa9f424cf5a796a8a67 to your computer and use it in GitHub Desktop.
Save anonymous/3aa9f424cf5a796a8a67 to your computer and use it in GitHub Desktop.
Why does `curl` post request work fine but not the `python_client` request?
curl -i -H "Content-Type: application/json" -X POST -d '{"url_id":"1", "results":{"pinterest":{"pin_count":"3"}, "facebook":{"comment_count":"101","like_count":"44","share_count":"99"}, "twitter":{"share_count":"77"}, "google":{"plus_count":"5"}}}' http://localhost:5000/api/v1/store_results
import requests
BASE_URL = "http://localhost:5000/api/v1/"
post_obj = {'results': {'facebook': {u'comment_count': 247,
'like_count': 406,
'share_count': 425},
'google': {'plus_count': 18},
'pinterest': {'pin_count': 3758},
'twitter': {'share_count': 21}},
'url_id': 1}
headers = {'Content-type': 'application/json'}
# POST results to API
p = requests.post(BASE_URL + 'store_results', data=json.dumps(post_obj))
print p
# 500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment