-->
Page 1 of 1

Correct way of performing HTTP post using ESP8266 Module

PostPosted: Fri Aug 05, 2016 11:45 am
by salmanali11053
Hey guys,
I wanna know correct procedure of doing HTTP post on a given URL using ESP8266 libraries.

Consider this URL. It is used to send SMS from experttexing.com by simply filling the parameters in the URL.

[url]
https://www.experttexting.com/ExptRestA ... &type=text
[/url]

Can I know how to do HTTP POST using WiFiClient library as well as HTTPClient library.
Waiting for helpful reply :)

Re: Correct way of performing HTTP post using ESP8266 Module

PostPosted: Fri Aug 05, 2016 1:20 pm
by salmanali11053
I'm trying like this using WiFi client library...
Code: Select all      client.println("POST /exptapi/exptsms.asmx/SendSMS HTTP/1.1");
      client.println("Host: www.experttexting.com");
      client.println("Connection: close");
      client.println("Content-Type: application/x-www-form-urlencoded");
      client.print("Content-Length: ");
      client.println(sttr.length());
      client.println("\r\n");
      client.println(sttr);


This is how client prints..
Code: Select allPOST /exptapi/exptsms.asmx/SendSMS HTTP/1.1
Host: www.experttexting.com
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 94


UserID=USERNAME&PWD=PASS!&APIKEY=APIKEY&FROM=DEFAULT&TO=+17133028183&MSG=MsgFromESP
Server Response....
HTTP/1.1 301 Moved Permanently



I am always getting 301 Moved Permanently as Response.. Please Help..

Re: Correct way of performing HTTP post using ESP8266 Module

PostPosted: Fri Aug 05, 2016 3:47 pm
by 8n1
Hi,

that's probably because the API only supports HTTPS connections.
[url]https://www.experttexting.com/appv2/documentation/index/
[/url]
Take a look at the HTTPSRequest example in the Arduino IDE and try modifying this.

Ps: I hope this aren't your real login credentials in the link you posted. Otherwise remove or change them quickly and change the password.

Re: Correct way of performing HTTP post using ESP8266 Module

PostPosted: Sat Aug 06, 2016 12:27 am
by salmanali11053
8n1 wrote:Hi,

that's probably because the API only supports HTTPS connections.
[url]https://www.experttexting.com/appv2/documentation/index/
[/url]
Take a look at the HTTPSRequest example in the Arduino IDE and try modifying this.

Ps: I hope this aren't your real login credentials in the link you posted. Otherwise remove or change them quickly and change the password.


Thanks for your response bro. yup those aren't my real credentials. I'll try by using HTTPSRequest class :)