Script API - v26.50.24
    Preparing search index...

    Main object for structuring a request.

    import { HttpRequest, HttpHeader, HttpRequestMethod, http } from '@minecraft/server-net';

    async function updateScore() {
    const req = new HttpRequest('http://localhost:3000/updateScore');

    req.body = JSON.stringify({
    score: 22,
    });

    req.method = HttpRequestMethod.Post;
    req.headers = [new HttpHeader('Content-Type', 'application/json'), new HttpHeader('auth', 'my-auth-token')];

    await http.request(req);
    }
    export class HttpRequest {
    body: minecraftserver.ISerializable | string;
    headers: HttpHeader[];
    method: HttpRequestMethod;
    timeout: number;
    uri: string;
    constructor(uri: string);
    addHeader(key: string, value: minecraftserveradmin.SecretString | string): HttpRequest;
    setBody(body: minecraftserver.ISerializable | string): HttpRequest;
    setHeaders(headers: HttpHeader[]): HttpRequest;
    setMethod(method: HttpRequestMethod): HttpRequest;
    setTimeout(timeout: number): HttpRequest;
    }
    Index

    Constructors

    Properties

    body: string | ISerializable

    Content of the body of the HTTP request.

    early-execution-editable - This property can be edited in early-execution mode.

    This property can't be read in early-execution mode.

    headers: HttpHeader[]

    A collection of HTTP headers to add to the outbound request.

    early-execution-editable - This property can be edited in early-execution mode.

    This property can't be read in early-execution mode.

    HTTP method (e.g., GET or PUT or PATCH) to use for making the request.

    early-execution-editable - This property can be edited in early-execution mode.

    This property can't be read in early-execution mode.

    timeout: number

    Amount of time, in seconds, before the request times out and is abandoned.

    early-execution-editable - This property can be edited in early-execution mode.

    This property can't be read in early-execution mode.

    uri: string

    The HTTP resource to access.

    early-execution-editable - This property can be edited in early-execution mode.

    This property can't be read in early-execution mode.

    Methods

    • Parameters

      • timeout: number

        The timeout value, in seconds.

      Returns HttpRequest

      Sets the maximum amount of time, in seconds, before the request times out and is cancelled.

      early-execution-allowed - This function can be called in early-execution mode.