HTTP

The HTTP service provides functionality for sending HTTP/HTTPS requests through the RPC methods HTTP.GET and HTTP.POST . Also a generic HTTP.Request RPC call is provided which allows sending several HTTP methods.

HTTP.GET​

This method allows fetching resources using HTTP/HTTPS GET requests.

Request​

Url address of the request. Required

Timeout in seconds. Optional

Type of the TCP socket. Optional

Default value, the built-in ca.pem TLS CA is used for HTTPS requests

The user-provided TLS CA is used for HTTPS requests, see Shelly.PutUserCA

Disabled certificate validation

Response​

Attributes in the result:

Code of the HTTP response

Msssage of the HTTP response

List of HTTP headers sent by the server

HTTP response body, if Content-Type is text or application/json

base64 encoded HTTP response body, if body is binary data. Maximum accepted length is 16KB (16384 bytes)

HTTP.POST​

This method allows posting data and receiving response using HTTP/HTTPS POST requests.

Request​

URL address of the request. Required

The request body. Required

base64 encoded binary request body. Either body or body_b64 is allowed

Value of the Content-Type header sent with the request Optional, default is application/json

Timeout in seconds. Optional

Type of the TCP socket. Optional

Default value, the built-in ca.pem TLS CA is used for HTTPS requests

The user-provided TLS CA is used for HTTPS requests, see Shelly.PutUserCA

Disabled certificate validation

Response​

Attributes in the result:

Code of the HTTP response

Message of the HTTP response

List of HTTP headers sent by the server

HTTP response body, if Content-Type is text or application/json

base64 encoded HTTP response body, if body is binary data. Maximum accepted length is 16KB (16384 bytes)

HTTP.Request​

This method allows sending several HTTP methods through HTTP/HTTPS and receiving response. Currently supported are GET, POST, PUT, HEAD and DELETE.

Request​

Method to send. Valid values are GET , POST , PUT , HEAD , DELETE . Required

URL address of the request. Required

The request body. Disallowed for GET and HEAD and Required for POST and PUT .

base64 encoded binary request body. Either body or body_b64 is allowed.

User supplied headers for the request, keys are header names and values are header values. Optional. User-Agent and Content-Length headers are disallowed and will be replaced with default values if specified. Contnet-Type header defaults to application/json for body and application/octet-stream for body_b64 if not specified.

Timeout in seconds. Optional

Type of the TCP socket. Optional

Default value, the built-in ca.pem TLS CA is used for HTTPS requests

The user-provided TLS CA is used for HTTPS requests, see Shelly.PutUserCA

Disabled certificate validation

Response​

Attributes in the result:

Code of the HTTP response

Message of the HTTP response

List of HTTP headers sent by the server

HTTP response body, if Content-Type is text or application/json

base64 encoded HTTP response body, if body is binary data. Maximum accepted length is 16KB (16384 bytes)

Examples​

HTTP.GET example​

http://192.168.33.1/rpc/HTTP.GET?url="http://10.33.53.21/rpc/Shelly.GetDeviceInfo" 
curl -X POST -d '>' http://$ /rpc 
mos --port $ call HTTP.GET '' 

Response

  "code": 200, "message": "OK", "headers":   "Server": "Mongoose/6.18", "Content-Type": "application/json", "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Headers": "*", "Content-Length": "232", "Connection": "close" >, "body": "\"id\":\"shellydev1-f008d1e2cb4c\", \"mac\":\"F008D1E2CB4C\", \"model\":\"SNSW-devX16EU\", \"gen\":2, \"fw_id\":\"20210908-124312/0.7.0-29-g0df1661-145-rpc-http-get-improvements-2\", \"ver\":\"0.7.0\", \"app\":\"Dev1\", \"auth_en\":false,\"auth_domain\":null>\r\n" > 
  "id": 1, "src": "shellydev1-f008d1e2cb4c", "params":   "code": 200, "message": "OK", "headers":   "Server": "Mongoose/6.18", "Content-Type": "application/json", "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Headers": "*", "Content-Length": "232", "Connection": "close" >, "body": "\"id\":\"shellydev1-f008d1e2cb4c\", \"mac\":\"F008D1E2CB4C\", \"model\":\"SNSW-devX16EU\", \"gen\":2, \"fw_id\":\"20210908-124312/0.7.0-29-g0df1661-145-rpc-http-get-improvements-2\", \"ver\":\"0.7.0\", \"app\":\"Dev1\", \"auth_en\":false,\"auth_domain\":null>\r\n" > > 
  "code": 200, "message": "OK", "headers":   "Server": "Mongoose/6.18", "Content-Type": "application/json", "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Headers": "*", "Content-Length": "232", "Connection": "close" >, "body": "\"id\":\"shellydev1-f008d1e2cb4c\", \"mac\":\"F008D1E2CB4C\", \"model\":\"SNSW-devX16EU\", \"gen\":2, \"fw_id\":\"20210908-124312/0.7.0-29-g0df1661-145-rpc-http-get-improvements-2\", \"ver\":\"0.7.0\", \"app\":\"Dev1\", \"auth_en\":false,\"auth_domain\":null>\r\n" > 

HTTP.POST example​

http://192.168.33.1/rpc/HTTP.POST?url="http://10.33.53.21/rpc/Sys.SetConfig"&body="config":"location":"tz":"UTC">>> 
curl -X POST -d '>>>>' http://$ /rpc