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
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 application/json
[2014-04-23 | 19:40:23: Opening:]
Request POST /hello
Connecting (HTTP):
[2014-04-23 | 19:40:23: Opened: 0]
> stream_write 0 7
... JSON data goes here ...
> http_read 0
HTTP response: 200
Chunked response

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

WICED Wi-Fi ForumsACKme Networks

0 Replies