HTTP AT Examples

This document provides detailed examples of running HTTP AT Command Set commands on module devices.

Important

  • The examples in this document assume the device is already connected to Wi-Fi.

  • Only partial HTTP client functionality is currently supported.

  • These examples may vary depending on the module. Refer to Firmware Versions and Feature Differences for command support on your module.

HTTP Client GET Request

This example sends a GET request to http://httpbin.org/get: set transport_type to 1 and opt to 2. For GET requests, content-type has no effect and any value may be used. Domain: httpbin.org; default HTTP port: 80; resource path: /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

Note:

  • The result you obtain may differ from the response shown above.

HTTP Client POST Request

This example uses http://httpbin.org as the HTTP server: set transport_type to 1 and opt to 3; data type: application/json; domain: httpbin.org; default HTTP port: 80; resource path: /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

Note:

  • The result you obtain may differ from the response shown above.

HTTPS Client POST (Long Text) Request

This example uses https://httpbin.org as the HTTP server: set transport_type to 2 and opt to 3; data type: application/json; domain: httpbin.org; default HTTPS port: 443; resource path: /post.

Command:

AT+HTTPRAW=2,3,"application/x-www-form-urlencoded","httpbin.org",443,"/post",123

>{"key1": 123,"key2": 123,"key3": 123,"key4": 123,"key5": 123,"key6": 123","key7": 123,"key8": 123,"key9": 123,"key10": 123}

Response:

 {
  "args": {},
  "data": "",
  "files": {},
  "form": {
 "{\"key1\": 123,\"key2\": 123,\"key3\": 123,\"key4\": 123,\"key5\": 123,\"key6\": 123\",\"key7\": 123,\"key8\": 123,\"key9\": 123,\"key10\": 123}": ""
 },
 "headers": {
 "Content-Length": "125",
 "Content-Type": "application/x-www-form-urlencoded",
 "Host": "httpbin.org",
 "X-Amzn-Trace-Id": "Root=1-64e56a61-147868f33dfa052e237b81b6"
 },
 "json": null,
 "origin": "120.234.24.230",
 "url": "https://httpbin.org/post"
 }

OK

Note:

  • The result you obtain may differ from the response shown above.