GSM shield - 400 Bad Request error

HI there,

I am trying to use a GSM shield to do a http Get request using GPRS.

This is the hardware I am using:

The problem I am having is that I keep seeing this output in the debug window:

AT#GPRS=1

+IP: 10.215.185.131

OK

AT
AT#SKTD=0,80,"www.bijlmereuro.net",0

CONNECT

GET /getparameters.php?location=id HTTP/1.1
Host: www.bijlmereuro.net


<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<

Something seems to be wrong in my GET request or in the timing of it. The ret_val = gsm.SendATCmdWaitResp and 10000, 1000, “OK”, 1 numbers are part of the GSM library of the GSM shield.

 ret_val = gsm.SendATCmdWaitResp("AT#GPRS=1", 10000, 1000, "OK", 1);  

  //Connect to webserver
  ret_val = gsm.SendATCmdWaitResp("AT#SKTD=0,80,\"www.bijlmereuro.net\",0", 10000, 1000, "CONNECT", 1);

  //Make the request
  ret_val = gsm.SendATCmdWaitResp("GET /getparameters.php?location=id HTTP/1.1\r\nHost: www.bijlmereuro.net\r\n\r\n", 10000, 1000, "", 1);

Can somebody help?

Thanks!

Christian

Forum wont let me post a link, even though it’s an example.

I’m getting the same problem
Sorted it connecting directly with Hyperteminal:

at the end of the GET line
at the end of the Host line

Control M being CR
Control J being LF

ANY OTHER COMBINATION RESULTED IN ERROR: even a LF after the first CR.

Don’t understand why but it works.

However when transferring this code to Arduino and getting it to send the same data string results in the same error again. No idea why. Tried all combinations of CR LF
Anyone had same the problem and solved whats going on??

Thanks
Andy

Hi

I actually managed to solve my own problem and am planing to write a tutorial for the GSM shield website for how to do it. So just quickly. The key thing to realise is that each time you do "gsm.SendATCmdWaitResp" is actually a carriage return and newline \r\n. So try this:

   ret_val = gsm.SendATCmdWaitResp("AT#SKTD=0,80,\"www.google.com\",0", 10000, 1000, "CONNECT", 1);
  ret_val = gsm.SendATCmdWaitResp("GET / HTTP/1.1", 10000, 1000, "", 1);
  ret_val = gsm.SendATCmdWaitResp("Host: www.google.com", 10000, 1000, "", 1);
  ret_val = gsm.SendATCmdWaitResp("\r\n", 10000, 1000, "", 1);
  debug();

Good luck!

best Christian

Hi Thanks for reply. First: I think they sold me an old version of GSM model.

The command AT#SKTD=0,80,\"www.google.com\",0 returns ERROR when sending direct from hyperterminal as does AT#SKTD?

I have been using AT#SKTSET = 0,80,\"www.google.com\",0,0 which does the same thing but is from an older command set.

Secondly: I have been sending with one function call ie: ret_val = gsm.SendATCmdWaitResp("GET / HTTP/1.1\r\nHost: www.google.co.uk\r\n", 10000, 1000, "", 1);

and still get Error 400 Any ideas??/

Thanks Andy

Hi Andy,

The GSM module on mine is GE863-QUAD. Check the firmware version on yours maybe you can upgrade it?

Regarding your code: In the terminal you don't need the escape slash '\' before the url. Also for http 1.1 you need the Host: www.google.com

Hi Christian, Thanks again for your help.

Ok found what's causing it... I'm using GPRS to access a PHP script on my server to update a database with data collected by the Arduino. I could do it from Hyperterminal directly to the GSM Shield, but not when testing with the Arduino.

I striped out all the DEBUG_PRINT commands and let my sketch just do it's stuff. All worked great. So the print _debugger is chucking odd characters back into the Shield, not much good as a debugger then!!

Thanks for pointing out the addition of CRLF inserted by the function. Bit naught that, it should just send what you tell it too.!!

Good luck with writting the tutorial.

All the best Andy