I am trying to send data to Thingtia.cloud.(an implementation of the Sentilo platform)
https://sentilo.readthedocs.io/en/latest/
The platform operators are the HTTP protocol methods.
In general, the operation associated with the operations used by Sentilo are:
In B4A it works correctly...
How to implement the PUT request in B4R?
HttpJob only implements POST
Sending the data through the POST request does not work. This is only useful if you are going to add new data, not to update
Response with POST :
Error:
Status: 405
{"code":405,"message":"HTTP POST method not allowed for the requested resource"}
https://sentilo.readthedocs.io/en/latest/
The platform operators are the HTTP protocol methods.
In general, the operation associated with the operations used by Sentilo are:
- GET: Request information.
- POST: Send new data.
- PUT: Update existing data.
- DELETE: Erase data.
In B4A it works correctly...
Enviar datos a Thingtia(PutString):
Sub enviardatosThingtia
'TEST
Dim datos As String
'Formato Json=> {"observations":[{ "value":"35"}]}
datos="{"&Chr(34)&"observations"&Chr(34)&":[{"&Chr(34)&"value"&Chr(34)&":"&Chr(34)&luminosidad&Chr(34)&"}]}"
jobSentilo.Initialize("JobPutThingtia", Me)'inicializar objeto conexión Server
jobSentilo.[B]PutString[/B]("http://api.thingtia.cloud/data/<usuario>/light/", datos)
jobSentilo.GetRequest.SetHeader("IDENTITY_KEY","[B]4d8999174................[/B]")
jobSentilo.GetRequest.SetContentType("application/json")
End Sub
How to implement the PUT request in B4R?
HttpJob only implements POST
Sending the data through the POST request does not work. This is only useful if you are going to add new data, not to update
POST Thingtia:
'formato json=>{"observations":[{" value":"14"}]}
....
WriteBytes(raf, "{""observations"":[{ ""value"":""")
WriteBytes(raf, S1)
WriteBytes(raf, """}]}")
HttpJob.AddHeader("IDENTITY_KEY", ID_KEY)
HttpJob.AddHeader("Content-Type", "application/json")
HttpJob.Post("http://api.thingtia.cloud/data/usuario/light/", bc.SubString2(buffer, 0, raf.CurrentPosition)) '[B]How implement PutString?[/B]
Response with POST :
Error:
Status: 405
{"code":405,"message":"HTTP POST method not allowed for the requested resource"}