HTTP AT Commands
Note
The HTTP AT commands are disabled by default.
You can refer to Configuring SDK (menuconfig) to enter CONFIG AT CMD
configuration and check Enable HTTP
to enable the HTTP AT command set.
AT+HTTPCONF
Description
Set global HTTP configuration. Once set, it takes effect permanently.
Command Format
AT+HTTPCONF=<timeout>[,<port>]
Response Format
Successful Response:
OK
Error Response:
ERROR:<error_no>
Parameters
- <timeout>: HTTP receive/send timeout (seconds)
Default value: 10
- <port>: HTTP server port
Range: [0,65535] (Default value 0)
0: HTTP uses port 80, HTTPS uses port 443
Error Codes
1: Parameter error
Example
Set HTTP receive/send timeout to 1 second, port to 12345:
AT+HTTPCONF=1,12345
OK
Restore default settings:
AT+HTTPCONF=10,0
OK
AT+HTTPHEADER
Description
Use Transparent Transmission (TT) Mode to set HTTP global request headers. Used to set HTTP request headers for GET/POST/PUT and other methods.
Once set, it applies to all subsequent related HTTP AT commonds until reconfigured, restarted, or reset with parameter 0
Note
This command is only supported in Host Control Mode.
Command Format
AT+HTTPHEADER=<req_header_len>
Response Format
Successful Response:
>>>
<req_header>
OK
Error Response:
ERROR:<error_no>
Parameters
- <req_header_len>: Length of a single HTTP request header
0: Clear and reset all set HTTP request headers
No length limit
- <req_header>:
Actual HTTP request header string
Error Codes
1: Parameter error
2: Memory allocation error
3: Failed to get data in TT mode
Example
Set two common request headers:
AT+HTTPHEADER=17
>>>
Connection: close
OK
AT+HTTPHEADER=30
>>>
Accept-Encoding: gzip, deflate
OK
Clear all request headers:
AT+HTTPHEADER=0
OK
AT+HTTPQUERY
Description
Query global HTTP configuration, including HTTP receive/send timeout, server port, and golobal request headers.
Command Format
AT+HTTPQUERY
Response Format
Successful Response:
Global HTTP configuration:
http_timeout: <HTTP receive/send timeout>
http_server_port: <Server port>
http_req_header_cnt: <Number of request headers>
http_req_header list:
<Request header 1>
<Request header 2>
...
OK
Error Response:
ERROR:<error_no>
Error Codes
1: Parameter error
Example
Query HTTP configuration:
AT+HTTPQUERY
Global HTTP configuration:
http_timeout: 10
http_server_port: 0
http_req_header_cnt: 2
http_req_header_list:
Connection: close
Accept-Encoding: gzip, deflate
OK
AT+HTTPGET
Description
Get HTTP resources.
Command Format
AT+HTTPGET=<host>,<path>,<conn_type>[,<cert_index>][,<req_header_cnt>,<req_header>...<req_header>]
Note
If this command specifies parameter request headers, they will be added to the HTTP message along with the global request headers configured using AT+HTTPHEADER.
Response Format
Successful Response:
+HTTPGET: HEADER LEN = <Header length>
+HTTPGET: HEADER DUMP START
<Header content>
+HTTPGET: HEADER DUMP END
+HTTPGET: BODY DUMP START
<Body content>
+HTTPGET: BODY DUMP END
+HTTPGET: BODY LEN = <Body length>
OK
Error Response:
ERROR:<error_no>
Parameters
<host>: Target host, no need for
http://
orhttps://
prefixSupports domain name or IPv4 address
Maximum length: 256 characters
<path>: Resource path
Default value: “/”
<conn_type>: HTTP connection type
1: HTTP
2: HTTPS (no certificate verification)
3: HTTPS (verify server certificate with CA certificate)
4: HTTPS (provide client certificate for server verification)
5: HTTPS (mutual authentication, both 3 and 4)
<cert_index>: Security certificate suite index, refer to AT Security Certificates
[1-10]
Only required when <conn_type> is 3-5
<req_header_cnt>:
Total number of request headers
<req_header>:
Actual request headers, multiple can be sent
Error Codes
1: Parameter error
2: Memory allocation error
3: Failed to read security certificate suite
4: Failed to send HTTP GET header
5: Failed to read HTTP response
Example
GET request example:
AT+HTTPGET=httpbin.org,/get,1
+HTTPGET: HEADER LEN = 230
+HTTPGET: HEADER DUMP START
HTTP/1.1 200 OK
Date: Mon, 06 Jan 2025 07:53:34 GMT
Content-Type: application/json
Content-Length: 196
Connection: keep-alive
Server: gunicorn/19.9.0
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
+HTTPGET: HEADER DUMP END
+HTTPGET: BODY DUMP START
{
"args": {},
"headers": {
"Host": "httpbin.org",
"X-Amzn-Trace-Id": "Root=1-677b8bfe-6faa4a9d7264e26b46397567"
},
"origin": "98.98.48.11",
"url": "http://httpbin.org/get"
}
+HTTPGET: BODY DUMP END
+HTTPGET: BODY LEN = 196
OK
AT+HTTPPOST
Description
Use Transparent Transmission (TT) Mode to send HTTP POST request.
Note
This command is only supported in Host Control Mode.
Command Format
AT+HTTPPOST=<host>,<path>,<conn_type>[,<cert_index>],<body_size>[,<req_header_cnt>,<req_header>...<req_header>]
Note
If this command specifies parameter request headers, they will be added to the HTTP message along with the global request headers configured using AT+HTTPHEADER.
Response Format
Successful Response:
>>>
<Post message content>
+HTTPPOST: HEADER LEN = <Header length>
+HTTPPOST: HEADER DUMP START
<Header content>
+HTTPPOST: HEADER DUMP END
+HTTPPOST: BODY DUMP START
<Body content>
+HTTPPOST: BODY DUMP END
+HTTPPOST: BODY LEN = <Body length>
OK
Error Response:
ERROR:<error_no>
Parameters
<host>: Target host, no need for
http://
orhttps://
prefixSupports domain name or IPv4 address
Maximum length: 256 characters
<path>: Resource path
Default value: “/”
<conn_type>: HTTP connection type
1: HTTP
2: HTTPS (no certificate verification)
3: HTTPS (verify server certificate with CA certificate)
4: HTTPS (provide client certificate for server verification)
5: HTTPS (mutual authentication, both 3 and 4)
<cert_index>: Security certificate suite index, refer to AT Security Certificates
[1-10]
Only required when <conn_type> is 3-5
<body_size>: Length of HTTP data to POST
No length limit
<req_header_cnt>:
Total number of request headers
<req_header>:
Actual request headers, multiple can be sent
Error Codes
1: Parameter error
2: Memory allocation error
3: Failed to read security certificate suite
4: Failed to send HTTP POST header
5: Failed to get data in TT mode
6: Failed to send HTTP POST body data
7: Failed to read HTTP response
Example
POST request example:
AT+HTTPPOST=httpbin.org,/post,2,,35,2,Connection: close,User-Agent: Ameba_iot
>>>
param1=test_data1¶m2=test_data2
+HTTPPOST: HEADER LEN = 225
+HTTPPOST: HEADER DUMP START
HTTP/1.1 200 OK
Date: Mon, 06 Jan 2025 07:49:09 GMT
Content-Type: application/json
Content-Length: 359
Connection: close
Server: gunicorn/19.9.0
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
+HTTPPOST: HEADER DUMP END
+HTTPPOST: BODY DUMP START
{
"args": {},
"data": "param1=test_data1¶m2=test_data2",
"files": {},
"form": {},
"headers": {
"Content-Length": "35",
"Host": "httpbin.org",
"User-Agent": "Ameba_iot",
"X-Amzn-Trace-Id": "Root=1-677b8af2-73ea1c6e376e5d1e672893b5"
},
"json": null,
"origin": "98.98.48.11",
"url": "https://httpbin.org/post"
}
+HTTPPOST: BODY DUMP END
+HTTPPOST: BODY LEN = 357
OK
AT+HTTPPUT
Description
Use Transparent Transmission (TT) Mode to send HTTP PUT request.
Note
This command is only supported in Host Control Mode.
Command Format
AT+HTTPPUT=<host>,<path>,<conn_type>[,<cert_index>],<body_size>[,<req_header_cnt>,<req_header>...<req_header>]
Note
If this command specifies parameter request headers, they will be added to the HTTP message along with the global request headers configured using AT+HTTPHEADER.
Response Format
Successful Response:
>>>
<Put message content>
+HTTPPUT: HEADER LEN = <Header length>
+HTTPPUT: HEADER DUMP START
<Header content>
+HTTPPUT: HEADER DUMP END
+HTTPPUT: BODY DUMP START
<Body content>
+HTTPPUT: BODY DUMP END
+HTTPPUT: BODY LEN = <Body length>
OK
Error Response:
ERROR:<error_no>
Parameters
<host>: Target host, no need for
http://
orhttps://
prefixSupports domain name or IPv4 address
Maximum length: 256 characters
<path>: Resource path
Default value: “/”
<conn_type>: HTTP connection type
1: HTTP
2: HTTPS (no certificate verification)
3: HTTPS (verify server certificate with CA certificate)
4: HTTPS (provide client certificate for server verification)
5: HTTPS (mutual authentication, both 3 and 4)
<cert_index>: Security certificate suite index, refer to AT Security Certificates
[1-10]
Only required when <conn_type> is 3-5
<body_size>: Length of HTTP data to PUT
No length limit
<req_header_cnt>:
Total number of request headers
<req_header>:
Actual request headers, multiple can be sent
Error Codes
1: Parameter error
2: Memory allocation error
3: Failed to read security certificate suite
4: Failed to send HTTP PUT header
5: Failed to get data in TT mode
6: Failed to send HTTP PUT body data
7: Failed to read HTTP response
Example
PUT request example:
AT+HTTPPUT=httpbin.org,/put,2,,35,2,Connection: close,User-Agent: Ameba_iot
>>>
param1=test_data1¶m2=test_data2
+HTTPPUT: HEADER LEN = 225
+HTTPPUT: HEADER DUMP START
HTTP/1.1 200 OK
Date: Mon, 06 Jan 2025 07:50:05 GMT
Content-Type: application/json
Content-Length: 358
Connection: close
Server: gunicorn/19.9.0
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
+HTTPPUT: HEADER DUMP END
+HTTPPUT: BODY DUMP START
{
"args": {},
"data": "param1=test_data1¶m2=test_data2",
"files": {},
"form": {},
"headers": {
"Content-Length": "35",
"Host": "httpbin.org",
"User-Agent": "Ameba_iot",
"X-Amzn-Trace-Id": "Root=1-677b8b2a-30de8616008ca27e176ccda2"
},
"json": null,
"origin": "98.98.48.11",
"url": "https://httpbin.org/put"
}
+HTTPPUT: BODY DUMP END
+HTTPPUT: BODY LEN = 356
OK
AT+HTTPDEL
Description
Delete the specified HTTP resource.
Command Format
AT+HTTPDEL=<host>,<path>,<conn_type>[,<cert_index>][,<req_header_cnt>,<req_header>...<req_header>]
Note
If this command specifies parameter request headers, they will be added to the HTTP message along with the global request headers configured using AT+HTTPHEADER.
Response Format
Successful Response:
+HTTPDEL: HEADER LEN = <Header length>
+HTTPDEL: HEADER DUMP START
<Header content>
+HTTPDEL: HEADER DUMP END
+HTTPDEL: BODY DUMP START
<Body content>
+HTTPDEL: BODY DUMP END
+HTTPDEL: BODY LEN = <Body length>
Error Response:
ERROR:<error_no>
Parameters
<host>: Target host, no need for
http://
orhttps://
prefixSupports domain name or IPv4 address
Maximum length: 256 characters
<path>: Resource path
Default value: “/”
<conn_type>: HTTP connection type
1: HTTP
2: HTTPS (no certificate verification)
3: HTTPS (verify server certificate with CA certificate)
4: HTTPS (provide client certificate for server verification)
5: HTTPS (mutual authentication, both 3 and 4)
<cert_index>: Security certificate suite index, refer to AT Security Certificates
[1-10]
Only required when <conn_type> is 3-5
<req_header_cnt>:
Total number of request headers
<req_header>:
Actual request headers, multiple can be sent
Error Codes
1: Parameter error
2: Memory allocation error
3: Failed to read security certificate suite
4: Failed to send HTTP DEL header
5: Failed to read HTTP response
Example
DELETE request example:
AT+HTTPDEL=httpbin.org,/delete,2
+HTTPDEL: HEADER LEN = 230
+HTTPDEL: HEADER DUMP START
HTTP/1.1 200 OK
Date: Mon, 06 Jan 2025 07:51:15 GMT
Content-Type: application/json
Content-Length: 263
Connection: keep-alive
Server: gunicorn/19.9.0
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
+HTTPDEL: HEADER DUMP END
+HTTPDEL: BODY DUMP START
{
"args": {},
"data": "",
"files": {},
"form": {},
"headers": {
"Host": "httpbin.org",
"X-Amzn-Trace-Id": "Root=1-677b8b73-43851d66543b1a534698c987"
},
"json": null,
"origin": "98.98.48.11",
"url": "https://httpbin.org/delete"
}
+HTTPDEL: BODY DUMP END
+HTTPDEL: BODY LEN = 263
OK