Adafruit I/O http data post body format

Hi Ravi, I saw your Adafruit I/O tutorial.I followed the step to get info on feeds and I was able to get the info in JSON format, but when i created a feed and then tried to post a value i get:

{“error”:“cannot process request - failed to save data to feed postvts. param is missing or the value is empty: datum”}

the body format i used is: {“datum”:{“value”:“89.0”}}

please help me sort out this issue.

Thanks in advance

Hi Gowtham,
Adafruit has changed a lot in their site. I am not sure if they have kept the API same. Try to go through their API documentation once and see if we are doing something wrong in packet format.

Hi Ravi, it turns out that i have to add content type in the header, after adding the content type the error is fixed.

Thanks & regards,
Gowtham

Glad that you got it working :slight_smile:
Regards,
Ravi

1 Like

Could you help me?
I have a similar error with my code: “error”:“cannot process request - failed to save data to feed postvts. param is missing or the value is empty: datum”. I tried to add content-type in header but it’s not work.
This is my code:
var options2 = {
method: ‘POST’,
url: “…”
headers: {
‘X-AIO-Key’: ‘680226b6e03b4376b9365d28ddexxxxx’,
‘Content-Type’: ‘application/json’
},
datum:{
“id”:“0E9YZQRYPBMNASPA2DF0C6ZDE0”,
“value”:“5dFhKkx2hC+erm1HQKqIsg==”,
“feed_id”:1219779,“feed_key”:“photocell”,
“created_at”:“2019-11-12T14:09:41Z”,
“location”:null,
“lat”:null,
“lon”:null,
“ele”:null,
“created_epoch”:1573567781,
“expiration”:“2019-12-12T14:09:41Z”
}
};
Is the syntax incorrect?