Issue POSTing data to Easyiot cloud

2 years 2 weeks ago #3273 by mamic2
hi guys,
i have problems while using POST to send data to Easyiot cloud.

In the examples given by Easyiot website, it connects to wifi network, then:
// Set up TCP connection.
String cmd = "AT+CIPSTART=\"TCP\",\"";
cmd += EIOT_CLOUD_ADDRESS;
cmd += "\",40404";
esp8266.println(cmd);

// Sending data
String url = "";
// URL: /RestApi/SetParameter/[instance id]/[parameter id]/[value]
url += "/RestApi/SetParameter/"+ String(EIOT_CLOUD_INSTANCE_PARAM_ID) + "/"+String(temp); // generate EasIoT cloud update parameter URL

esp8266.print(String("POST ") + url + " HTTP/1.1\r\n" +
"Host: " + String(EIOT_CLOUD_ADDRESS) + "\r\n" +
"Connection: close\r\n" +
"Content-Length: 0\r\n" +
"\r\n");


Since this code is not working for me, i would like ot ask if AT+CIPSEND=xxx is needed before POST.
I didnt find it in code provided by Easyiot website.
Thanks for helping me.
Ciao

Please Log in or Create an account to join the conversation.

2 years 2 weeks ago #3276 by EasyIoT

mamic2 wrote: hi guys,
i have problems while using POST to send data to Easyiot cloud.

In the examples given by Easyiot website, it connects to wifi network, then:
// Set up TCP connection.
String cmd = "AT+CIPSTART=\"TCP\",\"";
cmd += EIOT_CLOUD_ADDRESS;
cmd += "\",40404";
esp8266.println(cmd);

// Sending data
String url = "";
// URL: /RestApi/SetParameter/[instance id]/[parameter id]/[value]
url += "/RestApi/SetParameter/"+ String(EIOT_CLOUD_INSTANCE_PARAM_ID) + "/"+String(temp); // generate EasIoT cloud update parameter URL

esp8266.print(String("POST ") + url + " HTTP/1.1\r\n" +
"Host: " + String(EIOT_CLOUD_ADDRESS) + "\r\n" +
"Connection: close\r\n" +
"Content-Length: 0\r\n" +
"\r\n");


Since this code is not working for me, i would like ot ask if AT+CIPSEND=xxx is needed before POST.
I didnt find it in code provided by Easyiot website.
Thanks for helping me.
Ciao


Hi, I see you are using old REST API. I recommend you to use REST API V1. You can download library here:
iot-playground.com/blog/2-uncategorised/...apiv1-0-library-v1-0

This are two examples with this library:
iot-playground.com/blog/2-uncategorised/...ot-cloud-rest-api-v1
iot-playground.com/blog/2-uncategorised/...i-v1-and-email-alarm

Please Log in or Create an account to join the conversation.

2 years 2 weeks ago #3281 by mamic2
Thanks for the advice, but unfortunately im not able to solve my problem this way. I dont run my project on esp8266 but on arduino nano connected to esp8266 and the REST API V1 includes esp8266wifi.h and it doest work on nano.
Can you please advice how to send values to easyiot cloud using nano+esp8266? thanks

Please Log in or Create an account to join the conversation.

2 years 2 weeks ago #3283 by mamic2
i did a further step reading new library code but still no able to send data:
can somebody help? if i do same post request with http request software it works!


int t=40;
String url = "";
url += "POST /RestApi/v1.0/Parameter/" + String(PARAM1_ID) + "/Value/" + t;
String ccmmdd=String(url+" HTTP/1.1\r\n") +
"Host: " + String(IP) + ":" + String(PORT) + "\r\n" +
"EIOT-AuthToken: "+ String(TOKEN) + "\r\n" +
"Accept: */*\r\n" +
"Content-Length: 0\r\n" +
"Content-Type: application/x-www-form-urlencoded\r\n"+
"\r\n";
Serial.println(ccmmdd);
esp8266.print("AT+CIPSEND=");
esp8266.println(ccmmdd.length());
delay(500);
esp8266.print(ccmmdd);

Please Log in or Create an account to join the conversation.

1 year 5 months ago #3596 by Scalle0479
Hi, I'm having the same issue. Did you find the solution yet?

Please Log in or Create an account to join the conversation.

1 year 2 weeks ago #3803 by JonW
Hi this is what i did to get round not using ESP8266, i am using mega connected to the 8266 and works fine. now to get MQTT working on it.

String url = "";


String values("[{\"Id\": \""+parameterSetTemp+"\", \"Value\": \""+String(SetTemp)+"\" }]");

url = "POST /RestApi/v1.0/Parameter/Values";
client.print(String(url+" HTTP/1.1\r\n") +
"Host: " + String(EIOT_CLOUD_ADDRESS) + "\r\n" +
"EIOT-AuthToken: "+String(token) + "\r\n" +
"Connection: close\r\n" +
"Content-Length: " + values.length() +
"\n\n" +
values +
"\r\n");

Please Log in or Create an account to join the conversation.

Time to create page: 0.186 seconds