Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

GPRS Sim900 POST Method to web server problem

Status
Not open for further replies.

mono_girl

Newbie level 5
Joined
Feb 3, 2014
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
50
Hi Everyone

I am working on a project sim900(simcom) GPRS and i am using atmega324p micro controller
I am sending AT commands through micro-controller to web-server and i am watching the response of AT commands through UART on a terminal
I was able to send data to the remote server using Get Method
NOW,I want to send data to remote server using HTTP protocol POST Method
But i have "500 Internal server error" response and i don't know what's the problem
can you help me please ? :)
Here is the code
>> means command from micro-controller to GPRS
<<means response from GPRS on terminal

Code:
                   >>   AT 
                   >>  CR LF //carriage return and line feed
                   <<CR LF  OK  CR LF
		
	          >> AT+CPIN? 
                 >>  CR LF //carriage return and line feed
		 <<   CR LF +CPIN  READY  CR LF
                  <<CR LF ok CR LF
		  
		  >>AT+CGATT=1
                  >>  CR LF //carriage return and line feed
                  <<CR LF  OK  CR LF
                
                   >>AT+CREG?
                   >>  CR LF //carriage return and line feed
	           <<CR LF  OK  CR LF
                   << CR LF +CREG :0,1  CR LF
	
	         >> AT+SAPBR=3,1,"CONTYPE","GPRS"
                 >>  CR LF //carriage return and line feed
	         <<CR LF  OK  CR LF

	      

                 >> AT+SAPBR=3,1,"APN","mobinilweb"
                 >>  CR LF //carriage return and line feed
	         <<CR LF  OK  CR LF
		

	          >>AT+SAPBR=1,1;
                  >>  CR LF //carriage return and line feed
                  <<CR LF  OK  CR LF
		
	
		
                >>AT+HTTPINIT
                >>  CR LF //carriage return and line feed
                <<CR LF  OK  CR LF
               
		 >>AT+HTTPPARA="CID",1
		  >>  CR LF //carriage return and line feed
                  <<CR LF  OK  CR LF

                 >> AT+HTTPPARA="URL","http://myserver.com:80/Gprs2/Gprs_3/Service1.asmx/HelloWorld"
                 >>  CR LF //carriage return and line feed
                 <<CR LF  OK  CR LF
		
		  >>AT+HTTPDATA= 100,10000
		  >>  CR LF //carriage return and line feed
                  <<CR LF DOWNLOAD CR LF
                  
		
		>>POST /Gprs2/Gprs_3/Service1.asmx/HelloWorld HTTP/1.1      
                 >>  CR LF //carriage return and line feed                                                                                                                                                                                        
		  
		     
	         >>Host: myserver.com:80
                  >>  CR LF //carriage return and line feed
			
			
	          >> u=123                                  //data to be sent 
                  >>  CR LF //carriage return and line feed
                  >>  CR LF //carriage return and line feed
                   >>ctrl-Z
			       
	          >>AT+HTTPREAD
                  >>  CR LF //carriage return and line feed
                  << CR LF +HTTPREAD :100 CR LF
                  << POST /Gprs2/Gprs_3/Service1.asmx/HelloWorld HTTP/1.1
                   <<Host: myserver.com:80              
                    <<Content-Type: a CR LF
                    <<CR LF  OK  CR LF


                      
                      >>AT+HTTPACTION=1
                      >>  CR LF //carriage return and line feed
                      <<CR LF  OK  CR LF
                       <<CR LF +HTTPACTION:0,500,30 CR LF    
                  //here is 500 internal sever error,,the response should be +HTTPACTION:0,200,30 
                     
			        
			
		   >> AT+HTTPTERM
                   >>  CR LF //carriage return and line feed
                   <<CR LF  OK  CR LF


what i am doing wrong ? ! :(
 
Last edited:

Thank you for your help :)
The link you provided has actually helped me using HTTP GET method to send data to server
but there is no detailed guide about POST method
and i can't find out the problem within my code
any suggestions ??
 

Sir ,,i have already tried that as you can see from my first post ,,i also checked all posts here in forum and still my problem is not solved yet
May be i am missing something ,,i will check again :)
Thank you :)
 

Hello Mono I am again giving you a link only as I have used FTP, TCP , UDP
1st try like that
Connect SIM900 directly with PC using USB to UART and

https://m2msupport.net/m2msupport/module-tester/
open the following web this will run when you have installed Java then select the appropriate COM Port and there will be two option "GET" and "POST"
If it works with POST then it is Ok otherwise may be the URL over which you are sending may have some Problem
this I am guessing
 
@Mono,

1. Check whether you have got IP, using AT+SAPBR=2,1.
2. All the commands with respect to HTTP is fine..
3. But there is one thing which may be wrong...you had used, AT+HTTPDATA=100,10000<ENTER>, after which you have got <CR><LF>DOWNLOADN<CR><LF> which is fine...you had send the data also and you have terminated it using ctrl-z...this is also fine...but before getting "OK" response you had tried to read it again...
4. Also try to avoid using AT+HTTPREAD...dont use this...

I m not sure whether this might be the reason..pls check...

- - - Updated - - -

http://linksprite.com/wiki/index.php5?title=SIM900_GPRS/GSM_Shield

Also pls check the above website...might help you...
 
@embTRS
actually i am working on this project with my colleagues and i am doing the software part
i asked my colleague who designed the hardware and according to his design ,it is not possible to connect directly with PC
i can only send commands from micro ATMEGA324p through UART channel zero to GPRS then receive response from GPRS also through channel zero then forward the
response through UART channel one to terminal so i can watch the response !
Thank you :)
 

@kgshankar1980

i checked AT+SAPBR=2,1
and yes i got an IP

i removed AT+HTTPREAD but i still get 500 internal server error
i also have checked the link you provided
it illustrates the GET method not POST
i am still newbei and i don't have much information on this topic

is 500 internal server error means the problem on my side ,,or on the server side ??
can i check using another known URL ?
can you suggest a URL for me to check ?or it is not possible ?

Thank you for your help :)
 

@Mono,

>>AT+HTTPDATA= 100,10000
>> CR LF //carriage return and line feed
<<CR LF DOWNLOAD CR LF


>>POST /Gprs2/Gprs_3/Service1.asmx/HelloWorld HTTP/1.1
>> CR LF //carriage return and line feed


>>Host: myserver.com:80
>> CR LF //carriage return and line feed


>> u=123 //data to be sent
>> CR LF //carriage return and line feed
>> CR LF //carriage return and line feed
>>ctrl-Z

As per the datasheet there is nothing mentioned that you have to use CTRL-Z...From where you got this??

AT+HTTPDATA= 100,10000 ---> This command says that you are going to send 100 bytes of data....Instead of 100 bytes, you can also just mention 10 bytes of data and send the exact 10 bytes...

Whatever the data size you mention in your code, send the exact size of data, not 1 byte more or 1 byte less...

Do not use CTRL-Z as it is not mentioned in the datasheet...When the exact data mentioned as per the datasize in the AT command, you will receive "OK"...

Pls try as per above said way...

>>POST /Gprs2/Gprs_3/Service1.asmx/HelloWorld HTTP/1.1
>> CR LF //carriage return and line feed

>>Host: myserver.com:80
>> CR LF //carriage return and line feed


>> u=123 //data to be sent
>> CR LF //carriage return and line feed
>> CR LF //carriage return and line feed
>>ctrl-Z

In the above code, why you are sending CR LF again and again...And also i dont think POST is a command and it will work..

As per the AT Command, after <<CR LF DOWNLOAD CR LF the data received in the UART of GPRS will be sent to the WEBSERVER....all the bytes will be considered as simple data and it will transfer...

I think there is something wrong in your implementation...pls check it once again..

Try very simple, mention 10 bytes and send only 10 bytes of data through hyperteminal..and then update the result...

May be you can try the below way...And also since the URL is mentioned already u need not use it again in AT+HTTPPOST command..

>>AT+HTTPDATA= 10,10000
>> CR LF //carriage return and line feed
<<CR LF DOWNLOAD CR LF

>>1234567890

<<OK --------->U have to get this...

Try the above code...
 
@kgshankar1980

i saw on several threads here that other members are using POST command and ctrl-Z
here is one of them
https://www.edaboard.com/threads/126547/

and someone said that we should use complete post method
Code:
>>POST /Gprs2/Gprs_3/Service1.asmx/HelloWorld HTTP/1.1 
>> CR LF //carriage return and line feed 

>>Host: myserver.com:80
>> CR LF //carriage return and line feed

so now i am really confused :(
i will try the link you provided me and your method and i will let you know
Thank you :)
 

@mono,

If possible directly check with SIMCOM...it seems your code is ok...but there might a bad response from the network...so try to contact the module manufacturer directly regarding your issue..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top