I have small function? but It doesn’t work. somebody know what mistakes?
Hello @vandai,
We were able to reproduce this issue and our engineers are working to solve it. Will get back to you once it is fixed.
thanks!
with your library. everything is working.
but I want to try with your own code. I just wanted to do programming.
Hi @vandai
You have some mistakes:
- The
Content-Length
header should no have break lines between the key and the value, you should be replace println by print:
...
client.print("Content-Length: ")
int length = json.measureLength();
client.println(length); ...
- The endpoint
POST /api/v1.6/demo/Temperature/values/.....
does not exists, send values to one variable using devices so it should bePOST /api/v1.6/devices/demo/Temperature/values
...
client.println("POST /api/v1.6/devices/demo/temperature/values/?token=TOKEN HTTP/1.1");
...
- Additionally personally add the header
Connection: close
for close de connection TCP and free de memory.
Let me know if you have any other problem
Gustavo.
@vandai replace your code with the next code, don’t forget to change “YOUR_TOKEN” in my code.
client.println("POST /api/v1.6/devices/demo/temperature/values/?=YOUR_TOKEN HTTP/1.1");
client.println("Host: things.ubidots.com");
client.println("Content-Type: application/json");
client.println("Connection: Close");
client.print("Content-Length: ");
int length = json.measureLength();
client.println(length); Serial.rpint("length = "); Serial.println(length);
client.println();
String out;
json.printTo(out);
client.println(out);
client.println();
while (client.available() > 0) {
char c = client.read();
Serial.write(c);
}
thanks you very much!
Now It’s working!