HTTP AT Example

This document mainly provides for running on the module device HTTP AT command set A detailed example of the command.

Important

  • The examples described in this document are based on the premise that the device is connected to Wi-Fi.

  • Currently, only some HTTP client functions are supported.

  • This example has different adaptations for different modules. For specific differences, please go to the following steps to check the support

status of the module instruction: Firmware iterations and differences.

HTTP client GET request method

This example uses a get request to http://httpbin.org/get as an example: transport_type set to 1,opt set to 2,The domain name is httpbin.org, the default http port number is 80, and the resource path is /get.

Command:

AT+HTTPCLIENTLINE=1,2,application/x-www-form-urlencoded,httpbin.org,80,/get

Response:

  {
    "args": {},
    "headers": {
      "Host": "httpbin.org",
      "X-Amzn-Trace-Id": "Root=1-63c20ccc-0f33c8bf4bae7a8d3bb44270"
    },
    "origin": "120.234.24.230",
    "url": "http://httpbin.org/get"
  }

  OK

Description:
  • The results you get may differ from those in the response above.

HTTP client POST request method

This example uses http://httpbin.org as the HTTP server,transport_type set to 1,opt set to 3,the data type is application/json, the domain name is httpbin.org, the default http port number is 80, and the resource path is /post.

Command:

AT+HTTPCLIENTLINE=1,3,application/json,httpbin.org,80,/post,"{\"form\":{\"purpose\":\"test\"}}"

Response:

  {
    "args": {},
    "data": "{\"form\":{\"purpose\":\"test\"}}",
    "files": {},
    "form": {},
    "headers": {
      "Content-Length": "27",
      "Content-Type": "application/json",
      "Host": "httpbin.org",
      "X-Amzn-Trace-Id": "Root=1-63c2118c-552ac5547eedb78e37959f59"
    },
    "json": {
      "form": {
        "purpose": "test"
      }
    },
    "origin": "120.234.24.230",
    "url": "http://httpbin.org/post"
  }

  OK

Description:

-The results you get may differ from those in the response above.