Request
From UBot Studio
(Difference between revisions)
Line 19: | Line 19: | ||
<pre> | <pre> | ||
ui console view | ui console view | ||
− | log($request("https://jsonplaceholder.typicode.com/posts","POST", | + | log($request("https://jsonplaceholder.typicode.com/posts","POST","title: test |
+ | body: content | ||
+ | userId: 1","Content-type: application/json; charset=UTF-8")) | ||
</pre> | </pre> | ||
The script above sends a "POST" request to the specified URL with the given data and headers. The server's response is then logged. | The script above sends a "POST" request to the specified URL with the given data and headers. The server's response is then logged. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Latest revision as of 20:15, 12 July 2023
$request is a function that sends an HTTP request with specified parameters and returns the response in yaml format. This allows you to work directly with any API you'd like.
[edit] Parameters
URL: The URL to which the HTTP request is to be made.
Method: The HTTP method to use for the request. The options are "GET", "POST", "PUT", "DELETE".
Data: (optional) The data to send with the request. This should be an object in yaml or json format.
Headers: (optional) Any headers that should be sent with the request. This should be an object in yaml or json format.
[edit] Return Value
This function returns the server's response as a yaml object.
[edit] Example
ui console view log($request("https://jsonplaceholder.typicode.com/posts","POST","title: test body: content userId: 1","Content-type: application/json; charset=UTF-8"))
The script above sends a "POST" request to the specified URL with the given data and headers. The server's response is then logged.