Ubidots Community

[SOLVED] How do I set a variable on a single URL line?

This is a very newbie question. Non-programmere here…

I can read a variable via the following one line URL:

http://things.ubidots.com/api/v1.6/variables/<VariableID>?token=<myToken>&format=json

I then postprocess the JSON output and get my variable content.(I test that with the Live API page and see what I need to code for getting the value of the variable)

Now the other way, how do I change/set the same variable with a one line URL?
The examples are using curl -XPOST, but I need to be able to send just an URL which I put together before, and then postprocess the output again to check for success or error.

As an example (from the API doc):

# Request.
$ curl -XPOST -H 'Content-Type: application/json;' -H 'X-Auth-Token: XEcxqx3GTAWGTr4UJiWKk2RiiWEl04kZMSspFeW2BDBgdIe4Dj9CqCXvKLEA' -d '{"value": 23}' http://things.ubidots.com/api/v1.6/variables/5423a49e76254239d3c55718/values

How would I put this example into a single URL? I’m a little stuck here. Remember, I am actually not that much of a programmer.

Thanks
Dan

Hi Dan,

the standard APIs Ubidots not have this functionality, however you can use the Translate layer, then to send data in a single url or using GET method you can try:

curl -xGET "http://translate.ubidots.com/api/postvalue/?token=TOKEN&variable=ID_VARIABLE&value=2"

In your case:

curl -XGET "http://translate.ubidots.com/api/postvalue/?token=XEcxqx3GTAWGTr4UJiWKk2RiiWEl04kZMSspFeW2BDBgdIe4Dj9CqCXvKLEA&variable=5423a49e76254239d3c55718&value=23"

Best,
Gustavo.

1 Like

Thanks a lot Gustavo. I will try that.
Is this somewhere documented? I do not seem to find any mentioning of translate.ubidots.com in the API documentation.
(Well, except in this example, which I did not look at before: http://ubidots.com/docs/devices/ESP8266-arduino.html?highlight=translate)
Dan

No Dan, in Ubidots we are working to release a new layer with their documentation.

Regards,

using translate is not working.
When calling the provided url as an example

http://translate.ubidots.com/api/postvalue/?token=XEcxqx3GTAWGTr4UJiWKk2RiiWEl04kZMSspFeW2BDBgdIe4Dj9CqCXvKLEA&variable=5423a49e76254239d3c55718&value=23``

the result is

 {"detail":"Authentication credentials were not provided."}

Please check you’re using the right token