Ethernet GET/POST, Querystrings and ASP

G’day all,

I’d like to send some information to a Microsoft IIS server running classic asp via a querystring that’s generated on the Arduino and sent along to my webserver.

I thought this would be quite elementary, but it’s not proving to be that way IRL.

All the webpage does is parse out the querystring data and insert it into a database - here’s that page :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--#INCLUDE FILE="common.inc"-->

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>AutoUpload</title>
</head>
<body>
<%
	call CheckConxStatus
	ssql="insert into Test(TestData) values("
	ssql=ssql & stringsqlasp(request.querystring) & ")"
	response.write ssql & "
"
	gcnxconx.execute(ssql)
%>
</body>

</html>

CheckConxStatus is just a function I’ve written to make the connection to my sql server database.
stringsqlasp is a helper function to add quotes around strings for SQL
gcnxconx is the SQL Server database connection object

If I navigate to this page directly, it works perfectly well.
The URL I use is ‘http://autohouse.dode.com.au:8001/autoupload.asp?test=2&garb=yep’, and this is the URL the Arduino needs to reconstruct and send to the server.

The Adruino (withi ether shield fitted) seems to connect to the server, but no data is inserted to the database. I’ve tried ‘POST’ instead of ‘GET’, but that (unsurprisingly) made no difference. In all my asp pages that use the querystring, ‘GET’ is what I use.

Here’s the Arduino sketch :

#include <Ethernet.h>
 #include <SPI.h>
 

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char serverName[] = "http://autohouse.dode.com.au";
IPAddress ip(192,168,0,177);
IPAddress gateway(192,168,0,1);	
IPAddress subnet(255, 255, 255, 0);
 
EthernetClient client;
 
void setup()
 {
   Ethernet.begin(mac, ip);
   Serial.begin(9600);

  delay(1000);
  
  if (client.connect(serverName, 8001)) {

    Serial.print(millis());   
    Serial.print(":");
    Serial.print("Connected to ");
    Serial.println(serverName);
    Serial.println("Making HTTP request...");
    //construct HTTP GET request to app engine:    
    String toGet = "GET /autoupload.asp?test=2&garb=yep/ HTTP/1.0";    
    //Make the request    
    client.println(toGet);    
    //Pass a host header as well    
    client.print("HOST: ");
    client.println (serverName);    
    client.println();
    Serial.print(millis());   
    Serial.print(":");    
    Serial.println("HTTP request completed.");

    //client.println("GET http://autohouse.dode.com.au:8001/autoupload.asp?test=2&garb=yep");
  }else {
     Serial.println("connection failed");
   }

 }
 
void loop()
{
   if (client.available()) {
     char c = client.read();
     Serial.print(c);
   }
}

What am I missing here? Any and all comments are welcomed.

Thanks in advance :slight_smile:

Try to change this one:

String toGet = "GET /autoupload.asp?test=2&garb=yep/ HTTP/1.0";

to this:

String toGet = "GET /autoupload.asp?test=2&garb=yep/ HTTP/1.1";

The server name is NOT http://autohouse.dode.com.au. It is autohouse.dode.com.au.

Thanks for your replies.

PaulS' suggestion has solved my problem - thanks Paul :grin: