-
-
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?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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