Http-Client for uploading datas to ubidots


#1

Hello!

I had some good experiences with many devices of sending Data to the ubidots cloud, many thanks to all Ubidots supporter! Now i wanted to start with a Software client which updates Datas to Ubidots, the only thing is, that there is no example code for this type of software. The Software is from a german supplier cald IASNT which is a Soft PLC automation system. There are some HTTP PUT/Get Fuction already provided, which i only have to complete with some parameters, and there is the point where i need some help:

The Code which i want to change is from a Ubidots Example of the
Linkitone-board. The Upload part is as the folow:

_client.print(F("POST "));_
_client.print(URL);_
_client.print(F(" HTTP/1.1\r\n"));_
_client.print(F("Content-Type: application/json\r\n"));_
_//client.print(F("Connection: close\r\n"));_
_client.print(F("Host: "));_
_client.print(WEBSITE);_
_client.print(F("\r\n"));_
_client.print(F("Content-Length: "));_
_client.print(le);_
_client.print(F("\r\n"));_
_client.print(F("\r\n"));_
_client.print(payload);_
_client.println();_
_delay(5000);_
_client.stop();_

Now i would like to Upload these structure from this new software Client.
The problem is, that the client i want to use is written in SCL (structered control language) so there is no example for that language.
There is a HTTP Upload function in this client which looks like that:

_HTTP_REQ_

_(_

_HOST_ADDR := '192.168.0.101', // IP-Adresse der IP-CAM_

_REQ_RES_NAME := 'camera-cgi/com/ptz.cgi?move=left', //_

_USERNAME := 'Admin', // Benutzername_

_PASSWORD := 'Admin', // Passwort_

_REQ_METHOD := 1, // Request-Methode: 0 = GET, 1 = POST_

_SEND_REQ := bHttpReqSend,_

_STATUS => diStatus,_

_RESP_HDR_DATA => strRespHeaderData_

_);_

Now my qestion is that could it be a solution to replace the “REQ_RES_NAME” ->Sttring to the string which is combinated by the client.print(F)- structure?

I am also in contact with the other company, there is no online help available at the moment.

Thanks for any help and BR from switzerland!

MD53


#2

Hello @MD53,

According to your example the variable ‘REQ_RES_NAME’ should be the endpoint for your variable, according to our API it should be /api/v1.6/devices/datasource/

I think that this is not the main inconvenient with your device, maybe is to build properly the JSON dictionary to send the data, that’s what you should ask to your provider.

Regards


#3

Hi Jotathebest!
Thanks for yor answer, so for better understanding, in your opinion it should then look like:
/api/v1.6/devices/datasource/´camera-cgi/com/ptz.cgi?move=left’

Sorry, can you explain me short what you mean with JSON dictionary in my case?
Thanks and BR
Daniel


#4

Greetings,

Yes, I think that REW_RES_NAME is your endpoint, but I don’t figure in your example how to build the JSON dictionary to be sent. The JSON dictionary is the way as you can send data through HTTP Protocol, if you wan to send for example humidity and temperature values you should send to your endpoint url this dictionary:

{“temperature”: 10, “humidity”: 50} ( More info here )

All our libraries builds this dictionary on the background, so you need to know how to build the dictionary properly on your device.

Regards.


#5

Hi Jotathebest!
OK, thanks for your infrormation! I will come back if i have any news of my supplier,
BR