OSRS Plugin API
    Preparing search index...

    Enumeration RequestType

    Request Method supported by HTTP.

    Index

    Enumeration Members

    Enumeration Members

    GET: number

    Sends a request to get data from an endpoint. This example shows a get request that receives and decodes some JSON data when a 200 response code is received.

    local jsonData
    osrs.HTTP.request(
    WEB_URL,
    osrs.HTTP.RequestType.GET,
    {},
    {
    ["User-Agent"] = "osclient"
    },
    function(responseData, responseType, responseCode)
    if responseCode >= 200 and responseCode < 300 then
    osrs.print("Successfully retrieved data!")
    jsonData = json.decode(responseData)
    end
    end,
    osrs.HTTP.BodyType.NONE,
    {}
    )

    POST

    POST: number

    Sends data to an endpoint. This example shows a POST request that sends some data to a server and notifies what the response is when one is received.

    local data
    osrs.HTTP.request(
    WEB_URL,
    osrs.HTTP.RequestType.POST,
    {},
    {
    ["User-Agent"] = "osclient"
    },
    function(responseData, responseType, responseCode)
    if responseCode >= 400 then
    osrs.print("Failed to submit data.")
    end

    if responseCode >= 200 and responseCode < 300 then
    osrs.print("Successfully submitted data!")
    end
    end,
    osrs.HTTP.BodyType.URLENCODED,
    {
    ["data"] = tostring(data)
    }
    )