$httpRequest
Make HTTP requests with custom content and headers, and retrieve the response.
Usage
$httpRequest[URL;Method;Content;Header 1;Header 2;...]
Explanation: This function sends an HTTP request to the specified URL with the given method, content, and headers. It returns the content of the HTTP response.
Parameters:
- URL: The URL to send the request to.
- Method: The HTTP method to use (e.g.,
PUT
,GET
,POST
,DELETE
,HEAD
,PATCH
). If no method is provided, it defaults toGET
. - Content: The body of the HTTP request. The format should match the
Content-Type
header. For example, if you're sending JSON, set theContent-Type
header toapplication/json
and format the content as a JSON string. - Headers: A list of HTTP headers to include in the request. Each header should be in the format
Header: Value
. Separate multiple headers with semicolons.
Header Format:
Headers should be provided in the format Header-Name: Header-Value
. For example:
Content-Type: application/json
Authorization: Bearer your_api_token
Example (Sending a JSON Request):
This example demonstrates sending a POST request with JSON data to an API.
Important Notes:
Error Handling: This function does not automatically throw an error if the HTTP request returns a non-success status code (e.g., 404, 500). You must check the value of
$httpRequestStatus
after the request to ensure the status code is what you expect. For example:$let[response;$httpRequest[My API URL;get;;Content-Type: application/json]] $if[$httpRequestStatus!=200;Error: Request failed with status code $httpRequestStatus;Request successful: $response]
Response Size Limit: The response data must be less than 1 MB in size. Requests exceeding this limit will result in an error.