Chat freely about anything...

User avatar
By rant
#7943 Hi.
I have spend a day , trying to send a simple request to a server (3rd) but i couldn't do that .

So the module is working great, and i even get to the point where i do :

AT+CIPSTART=4,"TCP","api.server.com",443

I get "linked"

AT+CIPSEND=4,165

I get " > "


Than i am trying to form a get request to read a line from a data base, so i have this API which works great on a browser, but i cant seems to send that same one on the module.
the API request is-which works on a browser is :

https://xxxxxxxxNT5D6MVtC565xkEjBAkggTl ... TXcgRDCCRR

and i was trying to do it with :

GET /xxxxxXxxNT5D6MVtC565xkEjBAkggTlTMt1erNKv:javascript-key=xxxxxxxxB4gdANXSCGE0slnH0QKXhZ5OPf7ma4Gk@api.parse.com/1/classes/DATA/TXcgRDCCRR HTTP/1.0\r\n\r\n

I always get errors.
How do you use the module to send a regular http requests ,exactly how you do in a browser ?

Thanks a lot .
User avatar
By rant
#8028 Thanks very much , i cant provide a link because its a private data base.
But the question is more general , how do you "translate" a simple GET request that works on a regular browser, into the esp8266 GET/POST ?
How exactly do you build a link to the module, from the original link that works in any browser ?

the link (with some changes in the key field ) is :

Code: Select allhttps://xxxx4XmKNT5D6MVtC565xkEjBAkggTlTMt1erNKx:javascript-key=xxxxJ0XBB4gdANXSCGE0slnH0QKXhZ5OPf7ma4Gx@api.parse.com/1/classes/DATA/TXcgRDCCRR



1. how exactly does the GET request should look like from this link ?
2. how do you count the length of the request ? (what does it includes ? )

Any help would be great , thanks a lot !
User avatar
By sfyffe
#8033 Hi Rant,


I build mine like this:


String cmd = "AT+CIPSTART=1,\"TCP\",\"";
cmd += GatewayIP; //set to your target IP address
cmd += "\",";
cmd += Port; //set to whatever your port number is
cmd += "\r\n";
Serial1.print(cmd);
if(wait_for_esp_response(3000, "Linked")){
dbg.println("We are Linked");
}

cmd = GETConfig; //String GETConfig = "GET /methods/getsensorconfig?keyId=c35ba8g8b8h0s4sa156c251dad6c89b2";
cmd += "\r\n\r\n";
String cipsendcmd = "AT+CIPSEND=1,";
cipsendcmd += (cmd.length());
cipsendcmd += "\r\n";
Serial1.print(cipsendcmd);
// delay(500);
Serial1.print(cmd);


So your string my wind up looking like this

"GET /xxxx4XmKNT5D6MVtC565xkEjBAkggTlTMt1erNKx:javascript-key=xxxxJ0XBB4gdANXSCGE0slnH0QKXhZ5OPf7ma4Gx@api.parse.com/1/classes/DATA/TXcgRDCCRR"


so once you get the > symbol in the terminal window then cut and past the above line without the double quotes.

I think in your original post your HTTP/1.0\r\n\r\n at the end is making it not work.


You can test this a bit quicker with utilities such as "REST Console" which is a Chrome extension.


Stephen