The general idea is that all things you set with the HTTPPARA command will end up in the header of your request, and everything you pass with the HTTPDATA will be put on the body. Where your data needs to go depends on your system, I don’t know how it is configured or what it needs in order to work, that you’ll have to find for yourself.
I’ll assume that the contents of the JSON “headers” needs to be in the header of your HTTP request and the JSON “payload” has to go in the body. If that’s the case, consider the following:
- Keep in mind the AT Commands documentation, on page 257 it details the HTTPPARA command, and on 259 the HTTPDATA command.
- “Content-type” has its own field, you set it like this:
AT+HTTPPARA="CONTENT","application/json"
You’ll not be able to add that “;ty=1” on there, because the SIM800’s firmware will recognize that semi-colon as a different AT command and throw an error. If you can clarify what that is, we might come up with a solution.
- The rest of the elements in “headers” can only be passed with USERDATA. In theory you can only set one single “user defined” or “special” header, but (and I have not tested this) it seems that there is a way to circumvent this by using “\r\n” characters.
For example:
AT+HTTPPARA="USERDATA","X-M2M-Origin: XXXX\r\nX-M2M-RI: XX\r\nAccept: application/json"
- Finally, you use HTTPDATA to send the “payload”:
AT+HTTPDATA=44,10000
You then wait until you receive DOWNLOAD
as a response, then you write directly, character by character, what you want to send, without adding escape characters, extra double cuotes or anything; not even a final “enter”:
{“m2m”:“cin”:{“con”:“YYYY”}}
If you sent the correct amount of characters (or if in this case 10 seconds have passed), you’ll get an OK
response.
CONSIDERATIONS WHEN WRITING TEXT, ESCAPING CHARACTERS AND STUFF:
If you are using Arduino, and therefore C++/C, please remember, if you are “hard-coding” text (that is, writing a “string literal”) you have to escape characters like Carriage Return (“CR”), Line Feed (“LF”) and double cuotes. You escape a character in C++/C by appending a backslash; but this backslash will NOT be present in the final string, it’s just a way to tell C++/C how to handle those characters. So, if you read the string or print it you’ll not find the backslashes.