[SOLVED] Problem using variable in API POST

Hi,

I am doing a temperature sensing wireless device using arduino yun. I am using the API POST function to post data to Ubidots. I tested the code using sample values and it is working. But when i change the value to a variable, no data is posted in Ubidots. I modified the program code and implemented an increment code for simplicity. The basic is the same, I want to post a changing value using API POST.
BTW I got this code from https://www.youtube.com/watch?v=QdT38fpm924

The following is the full code for posting value.

include Process.h

float changingval = 0;

void setup() {
Bridge.begin();
SerialUSB.begin(9600);
while (!SerialUSB);
}

void loop() {

changingval = changingval + 1;
Serial.print(changingval);
runCurl();
delay (2000);

}

void runCurl() {
Process p;
p.begin(“curl”);
p.addParameter(“-X”);
p.addParameter(“POST”);
p.addParameter(“-H”);
p.addParameter(“Content-Type: application/json”);
p.addParameter(“-d”);
p.addParameter(“{"value" : 27}”);
p.addParameter(“http://things.ubidots.com/api/v1.6/devices/Home-Sensing/temperature/values?token=X5m8TUi5w6Iu7SAN2toMsBYxGyuJHR”);
p.run();

while (p.available() > 0) {
char c = p.read();
SerialUSB.print(c);
}

SerialUSB.flush();
}

When posting with sample value, the post function is working.

p.addParameter("{\"value\" : 27}");

But when I changed to variable, the code is not working.

p.addParameter("{\"value\" : \"changingval\"}");

Please help me troubleshoot my problem.
Thanks in advance.

Hello @vicky,

The value must be a float type, char or string without quotes (""), that’s the reason for what this line p.addParameter("{“value” : 27}") works for you and this not p.addParameter("{“value” : “changingval”}"), you should take off the quotes or download the Ubidots library and adapt the examples to your code.

Regards