HTTP GET Request

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

[OK]

AT+WSET=0,Mything

[OK]

AT+WSEC=0,WPA2,ihopethisworkswell

[OK]

AT+WNET=1

[OK]

AT+WJOIN

Joining : Mything

Successfully joined : Mything

[Link-Up Event]

IP Addr : 172.20.10.2

Gateway : 172.20.10.1

[OK]

AT+SCON=SO,TCN,52.73.47.183,80,5000,0

[OK]

[CONNECT 0]

AT+SSEND=0,170

GET http://httpbin.org/get User-Agent:Mozilla/5.0 HTTP/1.1

[ERROR: INVALID INPUT]

I tried following post 5834 on this forum, but even with translating the page I had a tough time.

I would appreciate any help you could give.

Hi GMK.

you should use the +SSEND command like below.
AT+SSEND=0,18{0x0d}

I hope this documents in below links will be helpful to you.
→ SSEND Command description
https://wizwiki.net/wiki/doku.php?id=products:wizfi250:wizfi250pg:start#method_of_setting_tcp_client_and_exchanging_data_in_command_mode

→ HTTPS Requset
https://wizwiki.net/wiki/doku.php?id=products:wizfi250:wizfi250pg:start#example_of_ssl_connection

Hi wizdaniel,

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.

GET / HTTP/1.1 {0x0d}{0x0a}

{0x0d}{0x0a}

[OK]

x0d}{0x0a}

[ERROR: INVALID INPUT]

{0x0d}{0x0a}

[ERROR: INVALID INPUT]

{0,192.168.1.13,80,490}HTTP/1.1 400 Bad Request

Content-Type: text/html; charset=us-ascii

Server: Microsoft-HTTPAPI/2.0

Date: Mon, 22 Jul 2019 19:58:15 GMT

Connection: close

Content-Length: 311

Bad Request

Bad Request


HTTP Error 400. The request is badly formed.

[DISCONNECT 0]

Hi

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.

POST /test/example HTTP/1.1{0x0d}{0x0a}
Host: www.abc.com{0x0d}{0x0a}
Content-Type: application/json{0x0d}{0x0a}
Content-Length: 18{0x0d}{0x0a}
{0x0d}{0x0a}
{"name": "daniel"}
{0x0d}{0x0a}
{0x0d}{0x0a}

Regards

Hi

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

Hi

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”.