I am having trouble performing a successful POST using an Arduino Mega2560 to send via xbee 3g modem (XBC-M5-UT-001).
Using the XCTU software from digi, through the serial terminal, I have been able to: -Configure the modem using AT commands -Send/Receive SMS messages -Send/Receive POST request
Furthermore, controlling the modem via the Arduino, I am able to: -Configure the modem using AT commands -Send/Receive SMS messages
But when I attempt to perform the same POST request successfully completed through the terminal, I get no response. I'm not sure if my POST is not getting through, or if the issue lies with the response.
The code below shows how I have been trying to send/receive this request:
Serial1.println("POST /loginAjax/ HTTP/1.1");
Serial1.println("Host: dev-aquhivedata.herokuapp.com");
Serial1.println("Content-Type: application/x-www-form-urlencoded");
Serial1.println("Content-Length: 28");
Serial1.println("");
Serial1.println("username=E***&pwd=A*********");
Serial1.println("");
Serial1.flush();
while(Serial1.available()) {
char c = Serial1.read();
Serial.print(c);
}
No Output...
Change your text delimiter, when you set up the digi modem they have you set your text delimiter to carriage return, or 0. The problem with this is there is a carriage return in each line of an HTTP packet, so if you dont change that, it will try and send each line as a packet ex. [Serial1.println("POST /loginAjax/ HTTP/1.1");] instead of the entire HTTP packet. I went with 24 which is the ascii char for "$".