[SOLVED] Simple http POST request from browser


#1

Hello!

I was wondering if there is an option to POST value from the browser (or use ApiTester without the Post data field).

Basically, if I paste the following URL into the browser, I am able to retrieve info:
http://industrial.api.ubidots.com/api/v1.6/devices/my-device-label/my-var/values?token=

Is there a way to post also data like this for example?
http://industrial.api.ubidots.com/api/v1.6/devices/my-device-label/my-var/values?token=&Content-Type=application/json&value=42

Now I know this is not the proper way, and not the most secure either, but as a quick testing.

Thanks for your help!


#2

Greetings, you may use the structure below:

https://industrial.ubidots.com/api/v1.6/devices/DEVICE-LABEL/?token=TOKEN&_method=post&VARIABLE-LABEL=1

All the best


#3

Hi,

Thanks for the quick reply!

I’m wondering if it only works with the industrial.ubidots.com domain, because I could not get it post with things.ubidots.com, unfortunatelly :confused:

Also, could you copy a link in which part of the API documentation can I find this? I went trough it many times, but I haven’t found it yet.

Thanks!


#4

Greetings, the endpoint only works with the endpoint dedicated for Industrial users. About your question of the docs, it is actually not documented as is not very usual to use a GET request for sending data.

All the best


#5

Is it possible to update location in this way also?

With TCP interface I can update variables and location using:

{useragent}|POST|{token}|{device_label}=>kph:32.6,batt:23.6,position:0$lat=-36.9685$lng=174.8633|end

I can update the variables kph and batt with a single command line of http successfully

http://industrial.ubidots.com/api/v1.6/devices/DEVICE-LABEL/?token=TOKEN&_method=post&kph=1&batt=22

but would like to add position variable to this. Is this possible?

PS. I canot send http body infomation (json) with the iot device, so need a single line solution as an alternative to TCP.

Any help greatly appreciated.

Regards
Rob.


#6

Greetings, actually there is not an endpoint that supports to send geo-location dots using a GET request, my advise is to use TCP or UDP if you cannot set a JSON char buffer in your device as these protocols should be supported by any IoT device.

If your project demands to use a GET request, my advise is to use the Ubifunction addon, with it you can customize your own HTTP request format to fit your needs. Keep in mind that the addon is only available for industrial users and has a monthly cost of U$29.

All the best


#7

Thanks for the reply jotathebest.
Yes, I’m currently using TCP and it is working ok. I will definitely look into the addon option.
Kindest Regards
Rob


#8

Nice Rob, if you need any help using UbiFunctions, just let me know in this post or write to the support channel using the embedded chat in your account.

All the best