Subsections of Requests

EXPRESSIONS

Request header

Creates a new request header as a key:value pair, where the key represents the header name and the value represents its content.

request (header|property) %string% %string%

Request Header Key

Retrieves the key (name) of a request header from a key:value pair, allowing you to identify the header’s purpose.

%request property%'s key
key of %request property%

Request Header Value

Retrieves the value of a request header from a key:value pair, allowing you to access the header’s content.

%request property%'s value
value of %request property%

EFFECTS

Asynchronous HTTP/S request

Executes a request with the specified method to the specified site using the specified headers and the specified request body. Returns the code and the body of the response.

[async[hronously]] request [%string%] to [url] %string% [with header[s] %request properties%] [(and|with) body %string%] [and store [[the] (body|result) in %object%] [and] [code in %object%]]
async request "GET" to url "https://crewpvp.xyz" and store the result in {_data} and code in {_code}

An asynchronous request cannot be used in functions where a value is returned. The result of an asynchronous request in this case will be <none>.

function asyncRequest() :: string:
    async request "GET" to url "https://crewpvp.xyz" and store the result in {_data} and code in {_code}
    return "{_data};{_code}"

command /asyncRequest:
    trigger:
        set {_result} to asyncRequest()
        send "{_result}" to player

Running the command /asyncRequest will return <none> instead of the expected result.

Synchronous HTTP/S request

Executes a request with the specified method to the specified site using the specified headers and the specified request body. Unlike asynchronous requests, this operation blocks the main thread until the response is received, which can lead to application unresponsiveness. Use synchronous requests only when blocking behavior is acceptable or necessary.

sync[hronously] request [%string%] to [url] %string% [with header[s] %request properties%] [(and|with) body %string%] [and store [[the] (body|result) in %object%] [and] [code in %object%]]

Blocking the main thread for the duration of the request can cause application unresponsiveness. Use this option wisely to avoid negatively impacting the user experience.