How can I upload data to ThingSpeak with a custom timestamp instead of using the server’s current time?
30 views (last 30 days)
Show older comments
I am currently using the ThingSpeak API to upload bat detection data from my project. I am trying to set the created_at timestamp to match the date and time captured from the image filenames. However, despite sending the created_at field in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ) via JSON in a POST request, ThingSpeak still records the current upload time instead of the provided timestamp.
Could you please clarify the correct way to send a custom timestamp so that ThingSpeak uses it instead of the current server time? Any guidance or examples would be greatly appreciated.
3 Comments
Christopher Stapels
ungefär 11 timmar ago
Edited: Walter Roberson
ungefär 7 timmar ago
I suspect your http library takes care of the url encoding so I suggest wating to check on that till later.
The time format you are using seems good, but its not clear from the code snippet what happens if there are no seconds or minutes in the folder name.
Thingspeak still records the time you wrote the data (I think its updated at), but also uses created_at for your plots. One possibility is confusion due to times. Thingspeak stores data in UTC, but plots in the time zone that your web browser is set at. I looked at your channel data though, and I dont see evidence of this problem with the data in there currently.
I used POSTMAN to create some test datapoints and ensure it works.
You can also use your web browser address field to test, but then you need to use the GET requests.
This format worked for me
or here is the format from the doc page.
POST api.thingspeak.com/update.json
Content-Type: application/json
{
"api_key": "XXXXXXXXXXXXXXXX"
"created_at": "2018-04-23 21:36:20 +0200",
"field1": "John Johnson",
"field3": 56,
"field4": 555,
"field5": 444,
"latitude": "",
"longitude": "",
"status": "Please check in!"
}
You can try outputting the POST you are using to the serial monitor to ensure its fromatted correctly.
Answers (0)
Communities
More Answers in the ThingSpeak Community
See Also
Categories
Find more on REST API in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!