HTTP AT Command Set

This chapter introduces the HTTP command set. Adaptations may vary across different modules. For details, see Firmware Versions and Feature Differences.

AT+HTTPCLIENTLIN: Send HTTP client request

Execute Command

Command:

AT+HTTPCLIENTLINE=<transport_type>,<opt>,<content-type>,<host>,<port>,<path>[,<data>]

Response:

Response length:<len> //response body 数据长度
<response> //获取的响应数据
OK

Parameters

  • <transport_type>: Request protocol.
    • 1: HTTP

    • 2: HTTPS

  • <opt>: Request type.
    • 2: GET

    • 3: POST

  • <content-type>: Request data type. (Effective for POST only; ignored for GET. Any string may be used; reference types are as follows)
    • application/x-www-form-urlencoded

    • application/json

    • multipart/form-data

    • text/xml

    • text/html

  • <host>: Server domain name or IP.
    • e.g. www.baidu.com or 192.168.1.100.

  • <port>: Port number.
    • Default: 80 for HTTP, 443 for HTTPS.

  • <path>: HTTP(S) path.
    • Default: “/”

  • <data>: Data carried in the request.
    • 1: When opt is GET, this data is carried in the path and must conform to HTTP format (?key1=value1&key2=value2 …)

    • 2: When opt is POST, this is the POST request body.

Description

  • Initiate an HTTP request.

Example

//GET请求
AT+HTTTPCLIENTLINE=1,2,"application/x-www-form-urlencoded","httpbin.org",80,"/get?key1=123&key2=456"

//POST请求
AT+HTTTPCLIENTLINE=1,3,"application/json","httpbin.org",80,"/post",{"key1": 123}

AT+HTTPRAW: Send HTTP client POST request (with long text)

Execute Command

Command:

AT+HTTPRAW=<transport_type>,<opt>,<content-type>,<host>,<port>,<path>,len

Response:

::

> //After receiving this character, start entering the data to send

OK //After the specified number of bytes is received, data is sent (any data allowed); OK is displayed when transmission completes

Parameters

  • <transport_type>: Request protocol.
    • 1: HTTP

    • 2: HTTPS

  • <opt>: Request type.
    • 3: POST

  • <content-type>: Request data type. (Effective for POST only; ignored for GET. Any string may be used; reference types are as follows)
    • application/x-www-form-urlencoded

    • application/json

    • multipart/form-data

    • text/xml

    • text/html

  • <host>: Server domain name or IP.
    • e.g. www.baidu.com or 192.168.1.100.

  • <port>: Port number.
    • Default: 80 for HTTP, 443 for HTTPS.

  • <path>: HTTP(S) path.
    • Default: “/”

  • <len>: Data carried in the request.
    • Request data length

Description

  • Initiate an HTTP request.

Example

AT+HTTPRAW=1,3,"application/json","httpbin.org",80,"/post",13

>{"key1": 123}