Sends an HTTP request.
This is a generic function. In most cases, specific functions such as http.get and http.post are simpler to use.
For more information, see Make an HTTP request.
Arguments
| Arguments | |
|---|---|
| method | 
 The HTTP request method. One of:  | 
| url | 
 The URL to send the request to. | 
| timeout | 
 The request timeout, in seconds (default:  | 
| body | The request body. If a Content-Typeheader is not specified and if the body value is bytes, the header is set toContent-Type: application/octet-stream; otherwise, the body is JSON-encoded and the header is set toContent-type: application/json; charset=utf-8. | 
| headers | The HTTP request headers. If present, must be a map of strings. If a Content-Typeheader is specified, the request body is encoded as prescribed. For example, it might be JSON or URL-encoded. | 
| query | Optional query parameters. If present, must be a map that will get URL-encoded and appended to the URL. The map values must be strings, ints, floats, booleans, or lists of those. | 
| auth | Optional authentication properties. If present, must be a map with typeattribute in["OIDC", "OAuth2"]. Ascopeskey is also supported. For details, see Make authenticated requests to Google Cloud APIs. | 
| private_service_name | 
 If present,  | 
| ca_certificate | 
 If present,  | 
Returns
The HTTP response as a map with body, code (status code), and headers
attributes.
Raised exceptions
| Exceptions | |
|---|---|
| ConnectionError | In case of a network problem (DNS failure, truncated response, etc.). | 
| ConnectionFailedError | When the connection is halted during transfer (failed connection, refused connection, etc.). | 
| TimeoutError | When the specified timeout is reached before the response is received. | 
| HttpError | If the response status is >= 400. | 
| ValueError | If timeout is > 1800. If the URL is invalid or if authType is present and URL is invalid for the given authType. If the private_service_name is invalid. If private_service_name is present and URL contains a port. If ca_certificate is present but is not of type bytes. | 
Examples
# Return titles of Wikipedia articles # related to "Canada" - searchWikipedia: call: http.request args: method: GET url: 'https://en.wikipedia.org/w/api.php' timeout: 20 # seconds headers: # map of strings "Accept-Charset": "utf-8" # Append search parameters to URL query: "action": "opensearch" "search": "Canada" result: x # `x` is a map and `x.body` is an array # Article titles are stored in # first index of `x.body` - returnStep: return: ${x.body[1]}