[SOLVED] SIM900 GSM unable to set "Content-type" in HTTP POST

I have some code that puts together a HTTP POST request with JSON data (GPS coordinates) and updates an IoT database. However, the response "Content-type must be application/json" is returned together with an error every time the request is sent.

So I logged the request with requestcatcher and the HTTP POST request looks like this. As you can see, no content type:

POST / HTTP/1.1
Host: ct.requestcatcher.com
Accept: */*
Connection: Keep-Alive
Content-Length: 42
User-Agent: SIMCOM_MODULE

{"longitude": 40.0015,"latitude": 90.5032}

The Arduino code is as follows:

void postDataThinger(char *httpDataLen, char* content)
{
  SIM900.println( F("AT+HTTPINIT") );
  delay(1000);
  updateSIM900();

  SIM900.println( F("AT+HTTPPARA=\"CID\",1") );
  delay(1000);
  updateSIM900();

  SIM900.println( F("AT+HTTPPARA=\"URL\",\"http://ct.requestcatcher.com\"") );
  delay(1000);
  updateSIM900();

  SIM900.println( F("AT+HTTPPARA=\"CONTENT\",\"application/json\"") );
  delay(1000);
  updateSIM900();

  SIM900.println(httpDataLen);
  delay(1000);
  updateSIM900();

  SIM900.println(content);
  delay(1000);
  updateSIM900();

  SIM900.println( F("AT+HTTPACTION=1") );
  delay(10000);
  updateSIM900();

  SIM900.println( F("AT+HTTPREAD"));
  delay(2000);
  updateSIM900();

  SIM900.println( F("AT+HTTPTERM") );
  delay(1000);
  updateSIM900();

}

I don't understand why this line of code do not work:

SIM900.println( F("AT+HTTPPARA=\"CONTENT\",\"application/json\"") );

The moden returns "OK" for all commands, this is the console output:

AT+HTTPINIT

OK
AT+HTTPPARA="CID",1

OK
AT+HTTPPARA="URL","http://ct.requestcatcher.com"

OK
AT+HTTPPARA="CONTENT","application/json"

OK
AT+HTTPDATA=42,10000

DOWNLOAD

OK
AT+HTTPACTION=1

OK

+HTTPACTION:1,301,0
AT+HTTPREAD

OK
AT+HTTPTERM

OK

Any ideas? I have also tried to replace the mentioned "CONTENT" command with:

AT+HTTPPARA="USERDATA","Content-Type: application/json"

..but this had no effect.

tormods:
I don't understand why this line of code do not work:

SIM900.println( F("AT+HTTPPARA=\"CONTENT\",\"application/json\"") );

SIM900.println( F("AT+HTTPPARA="Content-Type","application/json"") ); ??

Erik_Baas:
SIM900.println( F("AT+HTTPPARA="Content-Type","application/json"") ); ??

"CONTENT" should be correct parameter to the AT+HTTPPARA command. This is correct according to the specification: https://www.cooking-hacks.com/skin/frontend/default/cooking/pdf/SIM900_AT_Command_Manual.pdf

However, I suspect there might be some firmware issues, so I will check further if I'm able to update this.

SOLVED! It was indeed the SIM900 firmware. Apparently, the "CONTENT" option of the HTTPPARA command was not supported on older firmware of the chip. The first firmware that supports this function is B10 (1137B10SIM900M64_ST). A pain in the ass to upgrade, but did the trick :slight_smile: