0

Batch load via cURL and JSON file
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Batch load via cURL and JSON file

by tannkar on Fri Aug 23, 2019 3:47 pm

I currently have a free account and am attempting to create multiple records via cURL and a JSON file. I have attempted to do this on both a Mac and Windows system. When I run the cURL command below, I do not get any errors but it also does not provide a response.
Here is a sample of my command:
Code: Select all | TOGGLE FULL SIZE
curl -H "Content-Type: application/json" -d @batch.json -H "X-AIO-Key: {x-aio-key}" https://io.adafruit.com/api/v2/tannkar/feeds/sample.006/data/batch

Here is a sample of my JSON file:
Code: Select all | TOGGLE FULL SIZE
[{
"value": 112,
"created_at": "2019-08-01T06:00:00Z"
},
{
"value": 112.4,
"created_at": "2019-08-01T18:00:00Z"
}]

Can anyone provide some insight of what I may be doing wrong or are batch loads not allowed with a free account?

FYI:
The following syntax for a single record is accepted successfully using a Mac:
Code: Select all | TOGGLE FULL SIZE
curl -H "Content-Type: application/json" -d '{"value":173,"created_at":"2019-08-10T18:0000-06:00","lat":44.940591, "lon":"-102.455239"}' -H "X-AIO-Key: {x-aio-key]" https://io.adafruit.com/api/v2/tannkar/feeds/sample.392/data

The following syntax for a single record is accepted successfully using Windows:
Code: Select all | TOGGLE FULL SIZE
curl -H "Content-Type: application/json" -d "{\"value\":173,\"created_at\":\"2019-08-10T18:0000-06:00\",\"lat\":44.940591, \"lon\":\"-102.455239\"}" -H "X-AIO-Key: {x-aio-key]" https://io.adafruit.com/api/v2/tannkar/feeds/sample.392/data

tannkar
 
Posts: 2
Joined: Fri Apr 07, 2017 8:19 pm

Re: Batch load via cURL and JSON file

by jwcooper on Fri Aug 23, 2019 3:55 pm

Have you already created these feeds and are using the proper feed key as displayed on your feeds page?

https://io.adafruit.com/tannkar/feeds

Here is further documentation that may help:
https://io.adafruit.com/api/docs/#creat ... ta-records

You can batch upload with a free account. You will just need to be mindful of the data rate limitations as part of that account.

jwcooper
 
Posts: 670
Joined: Tue May 01, 2012 9:08 pm

Re: Batch load via cURL and JSON file

by tannkar on Fri Aug 23, 2019 5:55 pm

Yes, I have verified the feed keys. I have created the syntax for adding a single record (listed at the bottom of my first post) which was added successfully. I then modified that same line, removing the data information and substituting in the JSON filename and then adding the "/batch" to the end of the URL. Yet, when I post this command, it just comes back to the command prompt without any errors or a response from io.adafruit.com.
I wondered if it could be a JSON file issue, so I intentionally modified the JSON file with incorrect syntax and re-ran the command. When I do this it will return an error that it cannot parse the JSON file, so I believe it is not an issue with syntax in the JSON file. After this, I'm not sure what to try next. Any other suggestions would be much appreciated!
I did not want to post the actual code in my first post (slightly modified the feed_key and removed the AIO-key) but if it would help to see the actual code, please let me know.

tannkar
 
Posts: 2
Joined: Fri Apr 07, 2017 8:19 pm

Please be positive and constructive with your questions and comments.


cron