Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

HTTPPost ERROR 400


parthi Jul 31, 2023 06:07 AM

Hi All,

          I Have a CR300 cell215 logger with a Garmin GPS 16X HVS and a water-quality sonde on SDI12. I am trying to send the data from sonde data table to a https server. I can see the first attempt by the logger after compiling the program is successful and it's connecting with the server. But the subsequent requests are failing and I am receiving the below error. i believe the connection was never closed after the first attempt. what should I add to send data to the server at 15min intervals and append to the same file.?  any suggestions and help would be highly appreciated. Thanks

"2023-07-28 12:23:31.447",908,11.89984,0,"NAN","NAN",0,0,0,0,0,0,0,0,"NAN","NAN","NAN","NAN","NAN","NAN","NAN",0,0,"NAN","NAN","NAN",0,0,0,"","",3,"HTTP/1.1 200 OK Date: Fri, 28 Jul 2023 08:16:08 GMT Server: Apache X-Powered-By: PHP/7.2.24 Transfe","2023-07-28T08:16:08OK DONE ","https://netdl.ead.ae:443/mis_ott.php",118
"2023-07-28 14:30:19.651",5821,12.15977,0,"NAN","NAN",0,0,0,0,0,0,0,0,"NAN","NAN","NAN","NAN","NAN","NAN","NAN",0,0,"NAN","NAN","NAN",0,0,0,"","",3,"HTTP/1.1 400 Bad Request Date: Fri, 28 Jul 2023 10:16:08 GMT Server: Apache Content-Length: 226 Con","<!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.<br ","https://netdl.ead.ae:443/mis_ott.php",233

'Main Program
BeginProg  

  http_header = "" 'Indicates additional header information if required. An empty string may be used if no additional header information is needed.   

SERVER_PATH = "https://netdl.ead.ae:443/mis_ott.php" 'enter unique server path here  

'Main Scan

Scan(1,Sec,1,0)    'Default CR200 Series Datalogger Battery Voltage measurement 'BattV' SerialOpen (ComC2_Rx,38400,0,0,10000)
Battery(BattV)
SW12(1) 'Sets switch12 high for GPS and sonde power supply

'SDI-12 Multiprobe measurements 'Date', 'Time', 'Temperature', 'Turbidity'

If IfTime(13,15,Min)=True Then   

For i = 1 To 2 

  MProbe(i)= NAN 'If a probe is missing then NAN will be displayed

  Next i       

'Control I/O C1 will be SDI12 for WQ sonde


SDI12Recorder(MProbe(),C1,"0","M!",1,0)

EndIf

CallTable StationHealth

CallTable (Butinah_sonde_data)
NextScan
SlowSequence
Scan (15,Min,3,0)
GPS (GPS_Data(),ComC2_Rx,SE1,LOCAL_TIME_OFFSET*3600,1000,NMEAStrings,38400) 
CallTable (Butinah_GPS_Data)




NextScan  

SlowSequence  

Scan(1,Sec,3,0)     

  If TimeIntoInterval(1,15,Min) Then     

http_put_tx = HTTPPost (SERVER_PATH,"Butinah_sonde_data", http_put_response, http_header,0,0,Min,-1008)
  EndIf 

  NextScan
EndProg

best regards

parthi


Sam May 5, 2024 07:15 PM

I suggest trying the following, 

1) Clearing http_put_response and http_header before each call of HTTPPost.

2) Not negating the FileOption parameter. A negative FileOption is not applicable to HTTPPost. Appending would be a function of what ever service reprsented by mis_ott.php. Functions like LIST/APPEND are not applicable to HTTPPost, but are used by FTPClient.

http_put_response = ""
http_header = ""
http_put_tx = HTTPPost (SERVER_PATH,"Butinah_sonde_data", http_put_response, http_header,0,0,Min,1008)

 


HengesCheeky May 12, 2024 04:39 AM

Your suggestion to clear http_put_response and http_header before each call of HTTPPost is a good one, as it ensures that each request is independent and doesn’t carry over any residual data from the previous one.

Also, your point about not negating the FileOption parameter is valid. In the context of HTTPPost, a negative FileOption isn’t applicable. The appending function would be dependent on the service represented by mis_ott.php.

Here’s how you might modify your code:

http_put_response = ""
http_header = ""
http_put_tx = HTTPPost (SERVER_PATH,"Butinah_sonde_data", http_put_response, http_header,0,0,Min,1008)

 This should send data to the server at 15-minute intervals and append to the same file, assuming that the server-side script at mis_ott.php is set up to handle data in this way.

Remember to test your setup thoroughly to ensure that everything (especially geometry dash) is working as expected.

Log in or register to post/reply in the forum.