http.GET() response -2 but data are sent properly | ESP8266 Wi-Fi Module | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
http.GET() response -2 but data are sent properly
No permission to create posts
December 27, 2017
2:14 pm
Avatar
alcapar
New Member
Members
Forum Posts: 3
Member Since:
December 27, 2017
sp_UserOfflineSmall Offline

I need to check data are correctly handled. Now I try to get httpcode and always returns -2 but data are sent properly. The code is:

if (client.connect("api.thingspeak.com",80)) {
writeAPIKey = "key=XXXXXXXXXXX";
tsfield1Name = "&field1=10";
request_string = thingSpeakAddress;
request_string += "key=";
request_string += "XXXXXXXXXXXX";
request_string += "&";
request_string += "field5";
request_string += "=";
request_string += (tempe);
http.begin(request_string);
http.GET();
int httpCode = http.GET();
Serial.println(httpCode);
String payload = http.getString(); //Get the request response payload
Serial.println(payload);
http.end();

I am sure something is wrong.

December 28, 2017
9:27 pm
Avatar
Vinod

MathWorks
Members
Forum Posts: 202
Member Since:
May 1, 2016
sp_UserOfflineSmall Offline

Perhaps you want to try modifying one of the many examples listed here:

https://www.mathworks.com/help/thingspeak/examples.html

December 31, 2017
12:50 pm
Avatar
alcapar
New Member
Members
Forum Posts: 3
Member Since:
December 27, 2017
sp_UserOfflineSmall Offline

Thank you, I did it and it works.

Smile

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
21 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

BarryMaync, ThomasRougs, DonaldGen, prince, JrGordon, Elamsweems

Administrators: Hans: 387, lee: 457