Error 500 when sending POST with GPRS module SIM7100A, the data arrive null

1

and I tried to make a publication on the Thingspeak platform but the operation returns an incorrect request of 400, and I tried a publication with another test platform and got 200ok, but thingspeak did not work for me, the commands I use are as follows :

POST /update? HTTP/1.1\r\n
Host: api.thingspeak.com\r\n
Content-Type: application/x-www-form-urlencoded \r\n
Cache-Control: no-cache\r\n
\r\n\r\n
api_key=XXXXXXXXXXXXXXXXX&field1=4

I am using the Putty terminal with an arduino scketch as an intermediate between the module and the computer, the arduino code is as follows:

#include <SoftwareSerial.h>
SoftwareSerial GPRS(7, 8); //R T
unsigned char buffer[64]; // buffer array for data recieve over serial port
int count=0;     // counter for buffer array 
void setup()
{
GPRS.begin(115200);               // the GPRS baud rate   
Serial.begin(115200);             // the Serial port of Arduino baud rate.
}
void loop()
{
if (GPRS.available())              // if date is comming from softwareserial 
port ==> data is comming from gprs shield
{
while(GPRS.available())          // reading data into char array 
{
 buffer[count++]=GPRS.read();     // writing data into array
 if(count == 64)break;
}
Serial.write(buffer,count);            // if no data transmission ends, write 
buffer to hardware serial port
clearBufferArray();              // call clearBufferArray function to clear 
the storaged data from the array
count = 0;                       // set counter of while loop to zero
}
if (Serial.available())            // if data is available on hardwareserial 
port ==> data is comming from PC or notebook
 GPRS.write(Serial.read());       // write it to the GPRS shield
 }
 void clearBufferArray()              // function to clear buffer array
 {
 for (int i=0; i<count;i++)
 { buffer[i]=NULL;}                  // clear all index of array with 
  command 
  }
  }

I used thingspeak to test if the connection was successful, but testing on the platform that was used in production returns error 500, internal to the server, but when analyzing what it returns I can realize that the values apparently arrive null , then the response from the production server:     Production server error code

Obs: I'm using a ngnix web server, postgres database and an apiRest done in laravel 5

I am using the SIM7100A module with Arduino, sending the commands manually AT with Putty, and carried out tests with postman and insert the data satisfactorily

AT SIM7100 Command Documentation page 417 are the part of HTTP shipments

Thank you!

    
asked by Willy Exe 02.11.2018 в 11:50
source

1 answer

1

I have succeeded! The problem was not adding the Content Length within the shipping structure. Since I did not send the length of the string, I recognized it as null.

    
answered by 06.12.2018 / 11:02
source