How to use HTTP POST request in WICED Studio 4.0.1?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Honestly, I am not familiar with HTTP protocols,  We want to send a http post request with two key-values to a URI, then the http server will respond with json msgs.

The picture attached shows the test result through PC. Is there an example or API document for this?  Thanks a lot.QQ图片20161202165428.png

0 Likes
1 Solution
AndrewY_86
Employee
Employee
25 sign-ins 25 replies posted 10 replies posted

lzb@strivertech.com

The snip.httpbin_org application has an example of how to use the http_client library to send HTTP requests. It also demonstrates the JSON parser utility.

View solution in original post

6 Replies
AndrewY_86
Employee
Employee
25 sign-ins 25 replies posted 10 replies posted

lzb@strivertech.com

The snip.httpbin_org application has an example of how to use the http_client library to send HTTP requests. It also demonstrates the JSON parser utility.

Anonymous
Not applicable

Hi aky

      Thanks for your help, I have studied httpbin_org application. it helps but a little different. The httpbin_org application looks up the IP address from the given HOST, then setup a TCP connection, send a GET request. However, our customer's server requires to POST two key-values(Type and unique ID) first,  then the server will repond the target IP address and PORT for us to connect. What I don't know is how to POST the keys...

Finally, I did like this, first look the server's IP address, then send the keys-values by tcp client, recived the target ip address and port...then setup the real TCP connetion. if you any other information about HTTP POST, please kindly let me konw, thank you!

0 Likes

HTTP Methods for RESTful Services

The httpbin_org example is very similar to your use case. Change the SERVER_HOST to call.easyorder.cn, and the request_uri to /mall/.../check_watch (complete the URI). Your two key values should be written into the request with http_request_write_header and http_request_write_end_header. Change the request from HTTP_GET to HTTP_POST.

Then, you will be able to send the request and parse the response from the server

lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi aky,

      Thanks you for your patience, I modified the https_client application, it worked, and I got correct respond from our server. But the httpbin_org example still can't work. I spended up to two days to debug it...just want to figure out  where is the problem. Attached is my code, please check it at your convenience. Anyway I really want to say "Thanks" for your patience. 

0 Likes
lock attach
Attachments are accessible only for community members.

It seems the server was unhappy with the content length header. Using the exact content length fixed the issue.

Anonymous
Not applicable

Hi aky,

        It was perfectly solved by you, thank you very much! Maybe the example could help other developers also.