Hi there.
This code has been working fine on my Adafruit Fona and then all of a sudden I get Error 400. I must be missing something here, Ive read and reread the API documents and I just cant see my problem.
Code below:
String varString = "{“Volume_1”: " + String(vol1,2)+ ", “Volume_2”: " + String(vol2,2)+ ", “Average”: " + String(ave,2)+ “, “Error”: " + Error + “, “Signal”: " + String(csq)+ “}” ; //build string for upload
int num = varString.length();
SerialMon.println(“Sending String:”);
SerialMon.println(varString);
SerialMon.print(“With Length :”);
SerialMon.println(num);
SerialMon.print(F(“Connecting to “));
SerialMon.print(server);
SerialMon.println(“Please wait”);
if (client.connect(server,port)) {
client.print(F(“POST /api/v1.6/devices/”));
client.print(deviceLabel);
client.print(F(” HTTP/1.1\r\n”));
client.print(F(“Host: “));
client.print(server);
client.print(F(”\r\n”));
client.print(F(“X-Auth-Token: “));
client.print(token);
client.print(F(”\r\n”));
client.print(F(“Connection: close\r\n”));
client.print(F(“Content-Type: application/json\r\n”));
client.print(F(“Content-Length: “));
client.print(num);
client.print(F(”\r\n\r\n”));
client.print(varString);
client.print(F(”\r\n”));
SerialMon.print(F("Making request to Ubidots:\n"));
SerialMon.print("POST /api/v1.6/devices/");
SerialMon.print(deviceLabel);
SerialMon.print(" HTTP/1.1\r\n");
SerialMon.print("Host: ");
SerialMon.print(server);
SerialMon.print("\r\n");
SerialMon.print("X-Auth-Token: ");
SerialMon.print(token);
SerialMon.print("\r\n");
SerialMon.print("Connection: close\r\n");
SerialMon.print("Content-Type: application/json\r\n");
SerialMon.print("Content-Length: ");
SerialMon.print(num);
SerialMon.print("\r\n\r\n");
SerialMon.print(varString);
SerialMon.print("\r\n");
}
Thanks so much for your help!
Cheers
Matt