I'm using this code
import urllib
import json
import requests
base_url = 'https://api.yomdam.com/1.0/stats/log'
headers = { "Content-type": "application/json",
"Accept": "*/*",
"YOMDAM-API-KEY":"1303-M0G7-AA8D-WWDN-MM7W-XXXX"}
message ={"log_payload": {"activity": "TEST","date": 1444403649404,"Key1": "Value1","Key2": "Value2"}}
r = requests.post(base_url, headers=headers, params = json.dumps(message))
I keep getting
{"message": "Missing Input Data. Required keys: [u'log_payload']"}
I've tried same request using Postman on chrome and it works, I don't know why code won't work.
You should probably be using the data keyword parameter to the requests.post call ie.:
r = requests.post(base_url, headers=headers, data=json.dumps(message))
This way the json ends up in the post body instead of in the url.
See my previous answer today.
EDIT
as pointed out below and as verified here you could simplify the call to:
r = requests.post(base_url, headers=headers, json=message)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With