Dear Team,
I am trying to send an HTTP GET Request, and eventually Post Requests. I am using the site: httpbin.org/get to test my sequence, but am stumped.
AT
Thank you for the correction on my SSEND command, I think it has helped.
The next question is how are headers supposed to be formatted for this?
The example provided shows no header, other than the GET call, and I get an error 400 if I try like this. I also get error 400 the way I am formatting the command right now, so I would appreciate any help you could give me on this as well.
Edit: Thought I should add that I would like to know if there’s a place where I should insert the full url, as I am trying to access a specific page of an IIS server at this ip address. I have tried inserting the full header to access this site into this line but with no luck.
here is the HTTP request message sample to request hello.html page from the webserver running on abc.com
GET /hello.html HTTP/1.1{0x0d}{0x0a}
Host: www.abc.com{0x0d}{0x0a}
{0x0d}{0x0a}
if you want to send formed data to the server, you have to use a ‘POST’ method instead of the ‘GET’ like below.
Content-Type and Length are important parameters in the POST method.
Unfortunately, this formatting has not worked for me, I still receive bad request errors. As such I have several questions, and I should add that I’m using TeraTerm to connect to the device.
Where you put in “{0x0d}{0x0a}” does that have to be “{0x0d{0x0a}” or is it just to supposed to be carriage return line feed?
In the documentation for opening an SSL connection, it says to open the Socket in Command Mode, (0) not data mode (1), but when I put it in Command Mode, with 0 as the last input to the SCON command, I only receive an “INVALID INPUT” error, as opposed to when I put a 1 in, I receive:
HTTP/1.1 400 Bad Request
Content-Type: text/html
Date: Mon, 29 Jul 2019 20:26:11 GMT
Server: nginx
Content-Length: 166
Connection: keep-alive
400 Bad Request
400 Bad Request
nginx
which leads me to think a 1 is needed here. I am attaching the commands being sent (apart from the association to the access point) in the hopes that you can advise me further:
sendln 'AT+SCON=SO,TCN,52.22.188.80,80,5000,0'
pause 3
sendln 'AT+SSEND=0,,,18'
sendln 'GET /get HTTP/1.1'#13#10'Host: httpbin.org'#13#10''#13#10''
Note this is being sent via TeraTerm Macro, so the sendln and pause is just for TeraTerm, and the #13#10 is to indicate carriage return line feed to TeraTerm.
Any help you could provide would be greatly appreciated.
Regards
there is a example request to get some message from the httpbin.org as you tried.
GET /get HTTP/1.1{0x0d}{0x0a}
Host: 52.22.188.80:80{0x0d}{0x0a}{0x0d}{0x0a}
I guess that the message you sent was right formed message.
but message length was wrong. you should set the message length in the AT+SSEND the 18 to right length.
I prefer to set the length ‘44’ for above example.
AT+SSEND=0,,,44{0x0d}
GET /get HTTP/1.1{0x0d}{0x0a}
Host: 52.22.188.80:80{0x0d}{0x0a}{0x0d}{0x0a}
the {0x0d}{0x0a} means the carrige return&line feed.
be careful when you put the CR&LF using the options in the TeraTerm.
because AT+SSEND cmd only needs “CR”. and HTTP messages need “CR&LF”.