Sending data to server using GPRS

I am trying to send the data using gprs sim 800a,i am getting network error,before executing the AT+SAPBR=1,1 Signal strength will be good but as soon as AT+SAPBR=1,1 is executed led starts blinking continuously and returns response code 601.can anyone please help me how to resolve this issue? here is the AT commands used and the responses i got


"m2m:cin" :{\\r\n
"con" : "FIRE"}\r\n

601 HTTP response normally indicates your server is unavailable or busy. Test in fiddler first, and verify URL

Also, you have a double backslash in your message body:

"m2m:cin" :{\\r\n <--- Should be \r\n
"con" : "FIRE"}\r\n

If i send the data using wifi…it is working fine but with GPRS it is not working.
sir, In AT+HTTPDATA… should i need to include the size of \r,\n,^z and space characters also?
should i need to enter the data in a single line ?
Sir,Using wifi i used to send the data with security keys in the following way
but now i am including security keys and headers in userdata and payload part i am entering after i get download response…and in HTTPPARA URL i am writing “clienturl”+"/"+data" and client will be connected to VPN…sir can you please tell me whether the procedure which i am following is correct or not?

Yes you have to include each byte sent in the length.
WiFi is entirely different since you are not using commands, you are accessing functions directly.
Did you try to correct what @viedana suggested? There seems to be a extra slash.

I am using sim 808 module, and m2m airtel sim all cide is perfect but the last time connection establishing time get code we entred it shows error code 601. But the nor mal sim working very clearly what do http get error code 601

@jyothi, After you get the “DOWNLOAD” message to pass your content body to the SIM800 module, if you insert exactly the same amount of characters you’ve specified in HTTPDATA command, you’ll immediately get a “OK” response, signifying that all characters have been sent. Check if that’s the behavior you are getting (if there is a delay between the last character and the “OK”, it might just be that the time to input characters has finished).

In the HTTPPARA “URL” you should only input the website + the endpoint or address inside that website where you are trying to send your data. Your actual data should go after the “DOWNLOAD” message when you type the HTTPDATA command.

If you need to add multiple custom headers in the HTTPPARA “USERDATA”, one user in this forum has found that you can concatenate them with a “\r\n” in between each header item. You have to pass them all as a single string, if you call “USERDATA” multiple times, it only stores the last string passed. Also, remember that when you pass strings to the SIM800, they must be enclosed in double quotes (and written in a string literal, the double quote has to be preceded with a backslash to escape it).

1 Like

Thank you @viedana for your suggestion.i I tried to send the header items as a single string and i have also included\r\n in between each header items but i am getting error response for that.
This is my actual data to be posted
headers={“X-M2M-Origin”:“XXXX”,“Content-Type”:“application/json;ty=1”, X-M2M-RI":“XX”,“Accept”:“application/json”}
payload=’ ’ '{“m2m”:“cin”:{“con”:“YYYY”}} ’ ’ ’
If all this data can be send after i get the download response i,e without using USERDATA tag…How can i input the data?If you don’t mind can you please write and show me how i can pass this data ,because i have some confusion whether i should enter header&payload data in a single line or it should be seperated by , or &…?

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.
    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”:

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 OK response.


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.

Thank you @viedana for the detailed explanation.i tried in the same way but still i am getting the network error.ty=1 is the value given inorder to differentiate between the parent and child resourses. In the format itself it is given.If i include that either in the USERDATA or in the CONTENT i am getting OK response but after AT+HTTPACTION=1 i am getting network error…
If the network is busy i should get the same error when i tried sending data over wifi but in that case it is working fine,i don’t understand why am i getting this error?

what may be the reason…Any idea?

Ok, couple of things to try out:

  • In the string of AT+HTTPPARA="USERDATA","..." you don’t need to add the last \r\n at the very end, it will be added for you by the SIM800 (and remember that what separates the header from the body in a HTTP request is a double “enter”, so that might be giving you troubles).
  • If you can show an example of the AT+HTTPPARA="URL","..." you are passing to the SIM800, that would help us to see if that’s also ok.
  • On AT+HTTPDATA you say to the SIM800 “I’ll give you 44 characters to put in the body of the request” (that’s the “44” you write on AT+HTTPDATA=44,60000). But in there you have 44 characters only if you count the backslashes! I hope you are not typing them in your string! If you are writing the strings directly on a terminal console for example, you DO NOT need to “escape” the characters, only if you hardcode them on your C++/C/Arduino application. Also, for now I would suggest you to avoid inputting “enters” in the body for now, until we get it working.

hello @viedana ,
After i get download response i am entering the payload part and once when i get OK response i am pressing “enter” 2 times if i don’t input “enter” AT+HTTPACTION=1 will be added with the payload and gets printed on the putty terminal.
and again the same error…:neutral_face:

In url /R111 is the path where data to be posted.
when i tried using TCP after CIPSEND i entered the all the data and finally ^z.I got response as SEND OK but connection got closed immediately,no response from the server.

Oh ok, you are using Putty to write the AT commands, that’s good info. Can I ask you then how are you printing those “\r\n” in the terminal? if they where proper “enters” they will just show as a new line on the Putty terminal, not those 4 characters.

You mention the CIPSEND command… that is for the TCP/IP interface of the SIM800, which is another completely different toolset. As far as I know, you can’t use them together with the HTTP commands. Even the way you connect to the network is completely different. Check the IP Application Document from the manufacturer and check that you are following the same pattern shown:

  • To establish a GPRS connection, follow the steps in example on page 8 under the title “3.1. Bearer Configure” (the last step is only needed for when you whant to close the GPRS connection).
  • Then, follow steps on page 9 under title “3.3. HTTP Post Method”

Then tell me if those are the steps you are following, if there are any extra steps, please mention them.

yes @viedana i am following only those steps which are given in the IP Application document i,e 3.1 Bearer configure and 3.3 except last steps(closing GPRS context,HTTP terminate).
I am not using TCP commands with HTTP commands,what i said was i tried with TCP also when i didn’t get with HTTP.

“\r\n” is getting printed on the screen whenever i used and cursor will be in the same line…
you were saying “\r\n” should not be printed?

In normal operation of Putty at least, no, there should be no “\r\n” printed on the terminal when you are sending or receiving proper “enters”. You send “\r\n” by pressing enter on the terminal, and when you receive a “\r\n”, you just get a new line. So, for example:


Should instead be looking like this:


Also, something new to try out: @Anoopkumar (the user who mentioned the “\r\n” concatenation for the “USERDATA” parameters) informed us that the “\r\n” in between the parameters should have a double backslash, so your USERDATA command should look something like:


Those “\\r\\n” should be the only “\r\n” you should be seeing in your terminal. In all other cases you should not be typing the literal four characters \, r, \ and n, but instead just press Enter on your keyboard.

Ok @viedana
I tried this. i tried to input “\r\n” using ctrl+enter and ctrl+shift+enter respectively…for payload part it is working but inorder to seperate header items if i follow the same procedure i will get error…so i have seperated header items by"," …and i got the response as OK…but in the end again the same error.
I don’t know when this issue will be sorted out…
when i am sending data using wifi…i was using 2 ip address destination ip to send some keys and one more device ip where resourse has to be created using the object of class.
but in GPRS i am using only one IP address i,e “deviceurl”/R111…in the url…Is that the reason why i am not getting ? @viedana @RaviPujar Please help me to sort out the issue.
Thanks in advance

In Putty, you just need to press Enter, no need for ctrl+Enter to input “\r\n”.

As I said in the previous answer, for separating the especial headers you do NOT have to press enter, but rather write the 6 characters “\\r\\n”; so change those “,” by “\\r\\n” (again, those are 6 characters: backslash, backslash, r, backslash, backslash, n). And only use those six characters when separating the headers passed to the USERDATA parameter, in ALL other cases, just press Enter on the Putty terminal (check the snippet I’ve give you in my previous message for reference).

Important note: I have not tested this concatenation method, I’m just telling you what @Anoopkumar has found out, but it might be dependent on firmware version or some other factor.

Regarding your new inquiry, I’m not understanding where those snippets belong, it does not seem like C/C++ code, maybe that is part of your PHP server side code? In any case, I would suggest you the following:

  • We should probably take a step back and try to see if you can get a simple connection working, just to check if we have all our bases covered. Try to connect to something simple, without sessions, especial headers or anything. Even maybe just a GET request instead of a POST request first. Then switch to a POST and try to send data. And then check if we can add especial headers.
  • Maybe you can open a different question on the forum with that inquiry, so we can focus here on at least getting your connection working.