The use of the ESP8266 in the world of IoT

User avatar
By martinayotte
#51904 Good catch ! (I didn't even saw this mistake ...)

Also, although not related to the problem, a good suggestion is avoid doing many client.print() calls, it is better to concatenate multiple lines into a String and get it sent with a single client.print().
User avatar
By salmanali11053
#51934
bbx10node wrote:
Code: Select all     client.print("POST https://api.plivo.com/v1/Account/MYAUTID/Message/");
     client.print("Authorization: Basic\n");


The first line does not end with newline.

If adding a newline does not work, I would start capturing packets using tcpdump or wireshark to see what is really going on. I use a Linux firewall so it is possible to capture packets going to/from the Internet. I do know how you can do this using a regular WiFi router.


Hey I have tried adding new line too. I have tried these many things but no success at all.. Even plivo support doesn't reply me for this problem.
Code: Select allString body = "\n{\n\"src\" : \"+13303623231\",\n\"dst\" : \"+17133028183\",\n\"text\" : \"Input 1 Triggered,2nd Alert Msg from ESP8266 via PLIVO on 1/08/2016\"\n}";

        client.print("POST /v1/Account/MYAUTHID/Message/ HTTP/1.1\n");
        client.print("Host: api.plivo.com\n");
        client.print("Content-Type: application/json\n");
        client.print("Authorization: Basic TUFaSkRITldaSFlUS1dNVFZIWU06TXpSaU1XWm1OVGxrTmpGaE9XTmhOelJpWTJRMU5EaGlaR0ZqWVRKag==\n");
        client.print("Cache-Control: no-cache\n");
        client.print("Postman-Token: 02b0f9b7-234a-bc21-42c4-eb66c579a99d\n");
        client.print("Content-Length: ");
        client.print(body.length());
        client.print(body);


I have tried this too
Code: Select all      http.begin("https://api.plivo.com/v1/Account/MAZJDHNWZHYTKWMTVHYM/Message/");
      http.setAuthorization("MYAUTHID(Username)","MYTOKENNUMBER(Pass)");
      http.addHeader("Content-Type","application/json");
      http.POST(body);
      http.writeToStream(&Serial);
      http.end();
      CheckServerResponse();


please help me someone. I am about to give up :(
User avatar
By martinayotte
#51963 I've just seen other potential glitches :

First, you are sending the body variable right after sending the content length. So the header ending is missing, you should send 2 times CRLF.
Second, maybe the fact you are sending only CR without LF, it could be another issue.
User avatar
By salmanali11053
#52083
martinayotte wrote:I've just seen other potential glitches :

First, you are sending the body variable right after sending the content length. So the header ending is missing, you should send 2 times CRLF.
Second, maybe the fact you are sending only CR without LF, it could be another issue.


I've tried doing this too. Now I am getting a status code as 301 Moved Permanently. If I change the HTTP request from POST to GET I am getting 400 Bad Request. Any idea why I am getting 301 ?