http.get() function

The http.get() function is experimental and subject to change at any time. By using this function, you accept the risks of experimental functions.

The http.get() function submits an HTTP GET request to the specified URL and returns the HTTP status code, response body, and response headers.

Function type: Miscellaneous

import "experimental/http"

http.get(
  url: "http://localhost:8086/",
  headers: {x:"a", y:"b", z:"c"},
  timeout: 30s
)

Parameters

url

The URL to send the GET request to.

Data type: String

headers

Headers to include with the GET request.

Data type: Object

timeout

Timeout for the GET request. Default is 30s.

Data type: Duration

Response format

http.get returns an object that contains the following:

statusCode

The HTTP status code returned by the GET request.

Data type: Integer

body

The response body.

Data type: Byte Array

headers

Headers included with the response.

Data type: Object

Examples

Get the status of InfluxDB
import "experimental/http"

response = http.get(
    url: "http://localhost.com:8086/ping",
    headers: {Authorization: "Token mySuP3rS3cretT0k3n"}
  )

httpStatus = response.statusCode
responseBody = string(v: response.body)
responseHeaders = response.headers

This documentation is open source. See a typo? Please, open an issue.


Need help getting up and running? Get Support