[SOLVED] How to post multiple variables?

Hi,

I am puzzled about “POST api/v1.6/variables/{variable_id}/values”

I don’t want to post each variable separately via unique URL? Who came up with that?
I would like to use JSON as it was meant where each variable ID and it’s value is part of a JSON pair instead of using the generic variable ID “value” and doing it the hard way with unique URL for each?

Can someone give me a hand here? Thanks

Hi @bubba198,

Sure, there’s also an endpoint for that case. We call it “collections” as it is mostly used to update many variables in a single request, but you can also use it for one variable.

Here’s an example using curl, it should actually work if you copy-paste it in your terminal:

curl -i --header "Accept: application/json; indent=4" --header "Content-Type: application/json" --header "X-Auth-Token: XXXXXXXXXXXtlSnMd8ayOXXXXXX" -X POST -d '[{"variable": "547518da762542016381b2e9", "value":12}, {"variable": "547518e27625427f85fca05d", "value":43}]' http://things.ubidots.com/api/v1.6/collections/values
1 Like