The problem here is that you were passing in a proper form/urlencoded array of datapoints, while we were expecting a json-encoded string representation of the same. Which is kind of weird, and poorly documented [1], so shame on us!
The trouble here is deep… we return json data through the api, but we don’t really accept json data posted to the api – it’s all x-www-form-urlencoded data.
If you want to pass in a thing like an array of arrays (roadall
), or an array of datapoint parameters (create_all
), we were asking you to construct your array, then turn it into a json-parsable string, pass us that, then we parse the string as json on our end.
This is admittedly surprising / confusing (perhaps we should make it an actual json api for v2). You can send nested lists and things with x-www-form-urlencoded data as well, but it’s kinda ugly [2] if you’re trying to curl things, for example. Of course if you have a nice civilized library doing the dirty work on your http calls it’s beneath you to worry about such things anyway. So what I just did makes it so you can submit form-data-url-encoded arrays, or you can submit the json-encoded string version.
This should work for both roadall
and datapoints#create_all
in the api now.
[1] I think this used to be better documented and we may have murked it up in the past several months. I believe this because I know that people have successfully used the datapoints#create_all
endpoint in the past. Sorry!
[2] this example is borrowed from HTTParty
@example
# { name: "Bob",
# address: {
# street: '111 Ruby Ave.',
# city: 'Ruby Central',
# phones: ['111-111-1111', '222-222-2222']
# }
# }.to_params
# => "name=Bob&address[city]=Ruby Central&address[phones][]=111-111-1111&address[phones][]=222-222-2222&address[street]=111 Ruby Ave."