Skip to content
BasaltSoftware
Bedrock 1.26.60

Site colour

Discord
Esc

    ↑↓ moveEnter openEsc close

    Keyboard shortcuts
    Ctrl K
    Search the whole site, from any page
    /
    Jump to the sidebar search, or search the whole site where there isn't one
    Enter
    Open the top search result
    Esc
    Clear the search, or close this panel
    ?
    Show these shortcuts

    An HTTP request for HttpClient.request.

    Class in @minecraft/server-net

    An HTTP request for HttpClient.request. Each setter returns the request, so they chain.

    const request = new HttpRequest("https://example.org/api")
    .setMethod(HttpRequestMethod.Post)
    .addHeader("Content-Type", "application/json")
    .setBody(JSON.stringify({ hello: "world" }));
    import { HttpRequest } from '@minecraft/server-net';
    import { http, HttpRequest, HttpRequestMethod } from '@minecraft/server-net';
    async function report(message: string): Promise<void> {
    const request = new HttpRequest('https://example.com/api/report')
    .setMethod(HttpRequestMethod.Post)
    .addHeader('Content-Type', 'application/json')
    .setBody(JSON.stringify({ message }))
    .setTimeout(5);
    const response = await http.request(request);
    console.log(`Server answered ${response.status}`);
    }
    report('Basalt started');
    import { http, HttpRequest, HttpRequestMethod } from '@minecraft/server-net';
    async function report(message) {
    const request = new HttpRequest('https://example.com/api/report')
    .setMethod(HttpRequestMethod.Post)
    .addHeader('Content-Type', 'application/json')
    .setBody(JSON.stringify({ message }))
    .setTimeout(5);
    const response = await http.request(request);
    console.log(`Server answered ${response.status}`);
    }
    report('Basalt started');
    constructor(uri: string);
    Parameters
    uri
    string
    body: string;

    The body sent, as text; empty sends none.

    headers: HttpHeader[];
    method: HttpRequestMethod;

    Get unless set.

    timeout: number;

    Seconds to wait for the whole answer before rejecting with reason timeout; 10 unless set.

    uri: string;

    Where it goes: an http or https URI.

    addHeader(key: string, value: string): HttpRequest;
    Parameters
    key
    string
    value
    string
    Returns
    HttpRequest
    setBody(body: string): HttpRequest;
    Parameters
    body
    string
    Returns
    HttpRequest
    setHeaders(headers: HttpHeader[]): HttpRequest;
    Parameters
    headers
    HttpHeader[]
    Returns
    HttpRequest
    setMethod(method: HttpRequestMethod): HttpRequest;
    Parameters
    method
    HttpRequestMethod
    Returns
    HttpRequest
    setTimeout(timeout: number): HttpRequest;
    Parameters
    timeout
    number
    Returns
    HttpRequest

    HttpResponse.request, HttpClient.request