Skip to content

Contributed by Aixiao, organized by Ai-Thinker

Ai-WB2 Module HTTP Client POST Request Method

1. Preparation Hardware and software needed: an Ai-WB2 series module or development board, and a Type-C data cable. 2. Connecting to a Router

First make sure the module or development board is powered on and prints "ready", as shown below:

  1. Send AT+CWMODE=1;AT+CWJAP="WIFI_SSID","WIFI_PASSWORD". For example, the WiFi I am testing with has the name aithinker123 and the password 123456789, as shown below:

3. HTTP Client POST Request Method (For Posting Small Amounts of Data)

This example uses <http://httpbin.org> as the HTTP server, with the data type set to application/json, and sends an HTTP POST request.

Set opt to 3 (POST method) Set the URL to <http://httpbin.org/post> Set content-type to 1 (application/json) Set transport_type to 1 (HTTP_TRANSPORT_OVER_TCP) Command: AT+HTTPCLIENT=3,1,"<http://httpbin.org/post>",1,"{"form":{"purpose":"test"}}" As shown below:

Note:

The result you get may differ from the response shown above. 4. HTTP Client POST Request Method (Recommended)

If the amount of data you want to POST is relatively large and exceeds the 256-character length limit of a single AT command, we recommend using the AT+HTTPCPOST command. This example uses <http://httpbin.org> as the HTTP server, with the data type set to application/json, and posts data of a specified length. The command sets the number of HTTP header fields to 2: the connection field and the content-type field. The value of the connection field is keep-alive, and the value of the content-type field is application/json. Suppose the JSON data you want to post is as follows, with a length of 427 bytes. {"headers": {"Accept": "application/json","Accept-Encoding": "gzip, deflate","Accept-Language": "en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7","Content-Length": "0","Host": "httpbin.org","Origin": "<http://httpbin.org>","Referer": "<http://httpbin.org/>","User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36","X-Amzn-Trace-Id": "Root=1-6150581e-1ad4bd5254b4bf5218070413"}}

Command: AT+HTTPCPOST="<http://httpbin.org/post>",427,2,"connection: keep-alive","content-type: application/json"

As shown below:

Note:

After the AT command outputs the > character, special characters in the HTTP body do not need to be escaped, nor do they need to end with a newline (CR-LF). 5. Contact Us

That is all for this post. The goal is to help you quickly get started with development on the new product solution. More resources are available on our official website. Official website: <https://www.ai-thinker.com>

Development resources: <https://docs.ai-thinker.com/> Technical support: support@aithinker.com

Released under the MIT License. Build Time 2026-09-11 14:52:23