How to create an HTTP POST with WiConnect?

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

cross mob
Anonymous
Not applicable

WiConnect sits on top of WICED to enable a faster time to market through an easy to use API.

WiConnect runs as standard on all ACKme Networks Wi-Fi modules

HTTP Post Example

The following (fictitious) HTTP post example shows how to post data to an HTTP web server using the WiConnect HTTP API. The HTTP body data posted in this example is a small piece of JSON (sent using stream_write 0 7). Since the -o option is used with the

http_post command, a connection stream to the HTTP server is opened, but the HTTP post is queued locally on the module.


Queuing the HTTP post locally provides the ability to add HTTP headers using the

http_add_header command, and to post data in the HTTP body using the stream_write command. Once all headers and body data are queued, the HTTP post is sent to the server and completed using the http_read command.


Any response data received from the server may be read using stream_read.


> http_post -o example.com/hello application/json
[2014-04-23 | 19:40:23: Opening: example.com]
Request POST /hello
Connecting (HTTP): example.com:80
[2014-04-23 | 19:40:23: Opened: 0]
0
> stream_write 0 7
... JSON data goes here ...
Success
> http_read 0
HTTP response: 200
Chunked response
200

> stream_read 0 1000
{
    "response": "howdy!"
}
> stream_close 0
Closing: 0
[2014-04-23 | 19:40:40: Closed: 0]
Success

WICED Wi-Fi ForumsACKme Networks

0 Likes
0 Replies