http/1.1 406 not acceptable

I am working on a project that involves sim900 and a mysql server. When I am uploading the data to the server throws me an error.

SEND OK
HTTP/1.1 406 Not Acceptable
Date: Tue, 21 Ma

What does that mean or somebody can help me?

this is the arduino code.

//---------------------------------------------------------------------
mySerial.println(“AT+CGATT?”);
delay(1000);

ShowSerialData();

mySerial.println(“AT+CSTT=“wap.cingular””);//start task and setting the APN,
delay(1000);

ShowSerialData();

mySerial.println(“AT+CIICR”);//bring up wireless connection
delay(3000);

ShowSerialData();

mySerial.println(“AT+CIFSR”);//get local IP adress
delay(2000);

ShowSerialData();

mySerial.println(“AT+CIPSPRT=0”);
delay(3000);

ShowSerialData();

mySerial.println("AT+CIPSTART=“tcp”,“www.enriquesalas506.byethost7.com”,“80"”);//start up the connection
delay(3000);

ShowSerialData();

mySerial.println(“AT+CIPSEND”);//begin send data to remote server
delay(4000);
ShowSerialData();

mySerial.print( “GET /filesArduino/add.php?”);
delay(1000);
ShowSerialData();
mySerial.print(“lat=”);
delay(300);
ShowSerialData();
mySerial.print(flat,6);
delay(1000);
ShowSerialData();
mySerial.print("&&");
delay(300);
ShowSerialData();
mySerial.print(“lon=”);
delay(300);
ShowSerialData();
mySerial.print(flon,6);
delay(1000);
ShowSerialData();
mySerial.print("&&");
delay(300);
ShowSerialData();
mySerial.print(“time=”);
delay(300);
ShowSerialData();
mySerial.print(“111”);
delay(300);
ShowSerialData();
mySerial.println(“HTTP/1.1”);
delay(1000);
ShowSerialData();
mySerial.println( “Host: www.enriquesalas506.byethost7.com” );
delay(1500);
ShowSerialData();
mySerial.println( “Content-Type: application/x-www-form-urlencoded” );
delay(1500);
ShowSerialData();
mySerial.println( “Connection: close” );
delay(1500);
ShowSerialData();
mySerial.println();
delay(300);
ShowSerialData();
mySerial.println();
delay(300);
ShowSerialData();

mySerial.println((char)26);//sending
delay(10000);//waitting for reply, important! the time is base on the condition of internet
mySerial.println();

ShowSerialData();

mySerial.println(“AT+CIPCLOSE”);//close the connection
delay(100);
ShowSerialData();
//-------------------------------ANTENNA
Serial.println();
Serial.println(“GPS”);
Serial.println();
delay(5000);

//----------------------------------------------------------

this is the php code used

add.php
//-----------------------------------------------------------

<?php include("conec.php"); $link=Conection(); $Sql="insert into jsalasm (latitude,longitude,gpstime) values ('".$_GET["lat"]."', '".$_GET["lon"]."', '".$_GET["time"]."')"; mysql_query($Sql,$link); header("Location: insertareg.php"); ?>

//--------------------------------------------------------------------

conec.php
/----------------------------------------------------------------------/

<?php function Conection(){ if (!($link=mysql_connect("sql111.XXXXXXXHost","XXXXUserXXX","XXXPasswordXXX"))) { exit(); } if (!mysql_select_db("XXXdatabase",$link)){ exit(); } return $link; } ?>

//-------------------------------------------------------------------

can somebody explain what is the mistake i am making of it is a sever error? because i already tried to use the get function from the browser and I already upload the data to the database. But only through browser

Your hosting provider has implemented mod_security and it's apparently causing you issues (that's why you get 406 responses).

If you had access to the mod_security logs you'd know what the exact problem is -- otherwise it's a guess. I do see that your request has a missing space between the time parameter ("time=111") and "HTTP/1.1". You've also got a lot of delay() between lines in your request; you should remove those. You're also doing "mySerial.print("&&")" when it should be just one "&".

It may also be possible to disable the mod_security engine with an .htaccess file: http://modsecurity.org/documentation/modsecurity-apache/1.9.3/html-multipage/03-configuration.html

You probably also want to get a dump of all of your request headers so you can see what you're actually sending from your Arduino (find obvious mistakes): http://php.net/manual/en/function.getallheaders.php

I found kind of curious this issue because a few weeks ago, the code was running perfectly. Then I was trying to run it again and I was receiving "error 406" not acceptable. And I was trying to look up what does error 406 means. And It was related to a server error. (probably because I was using a free web hosting D: ) So what I am doing now it is that I paid around $5.00 on a host on GoDaddy and I hope that everything runs fine now.

Note: I already deleted the delays and spaced the line mySerial.println(" HTTP/1.1"); but I am still getting the same annoying and evil http 406 Not acceptable error :'''c

About those headers can you explain me more that?

enriquesalas506:
About those headers can you explain me more that?

In your add.php it might be helpful to see what you’re sending to the server:

<?php
echo getenv("REQUEST_METHOD") . " " . getenv("REQUEST_URI") . " " . getenv("SERVER_PROTOCOL") . "
\n";

foreach (getallheaders() as $name => $value) {
    echo "$name: $value
\n";
}
?>

Then, for debugging, you can just telnet to www.enriquesalas506.byethost7.com port 80 and paste those headers (and add an extra blank line at the end). It’s just a simple way of messing with things so you can get it right.

MAN - you are the neat! Really appreciate your help man. Thanks :D I just get it working and you were right about the security setting issue. And about the headers really helpful! Now I can sleep again :')