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:
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.
AT+HTTPPARA="USERDATA","X-M2M-Origin: XXXX\r\nX-M2M-RI: XX\r\nAccept: application/json"
- Finally, you use HTTPDATA to send the “payload”:
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”:
If you sent the correct amount of characters (or if in this case 10 seconds have passed), you’ll get an
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.