HttpService

HttpService : Instance

Overview

Properties

HttpEnabled

bool

HttpEnabled is a boolean property that indicates whether HTTP requests can be sent to external endpoint(API Server, Website).

Code Samples

Methods

GenerateGUID

The GenerateGUID method generates a globally unique identifier (GUID).

Parameters

bool bInWrapInCurlyBraces

Return

string

Code Samples

local HttpService = game:GetService("HttpService")
local Result = HttpService:GenerateGUID(false)

print(Result)

GetAsync

Request HTTP GET message

Parameters

string InUrl

bool InNoCache

Value InHeaders

Return

string

Code Samples

local HttpService = game:GetService("HttpService")
local baseUrl = "HTTP URL을 입력하세요"

local success, errorMessageOrResult, response = nil, nil, nil

success, errorMessageOrResult = pcall(function()
    response = HttpService:GetAsync(baseUrl)
end)

print("Success : ", success)
print("ErrorMessageOrResult : ", errorMessageOrResult)
print("Response : ", response)

JSONDecode

Decode JSON from the string and convert it to Lua Table

Parameters

string InInput

Return

Value

Code Samples

local HttpService = game:GetService("HttpService")

local data = HttpService:JSONDecode(jsonData)
print(data)

JSONEncode

Generate JSON String from Lua Table

Parameters

Value InInput

Return

string

Code Samples

local HttpService = game:GetService("HttpService")

local data = 
{
    ["message"] = "Hello OVERDARE!",
    ["data"] = 10,
}
local jsonData = HttpService:JSONEncode(data)

PostAsync

Send HTTP Post message

Parameters

string InUrl

string InData

Enum.HttpContentType InContentType

bool InCompress

Value InHeaders

Return

string

Code Samples

local HttpService = game:GetService("HttpService")
local baseUrl = "HTTP URL을 입력하세요"

local success, errorMessageOrResult, response = nil, nil, nil

success, errorMessageOrResult = pcall(function()
    local data = 
    {
        ["message"] = "Hello OVERDARE!",
        ["data"] = 10,
    }
    local jsonData = HttpService:JSONEncode(data)

    local contentType = Enum.HttpContentType.ApplicationJson
    local compress = false
    local headers = {}
    response = HttpService:PostAsync(baseUrl, jsonData, contentType, compress, headers)
end)

print("Success : ", success)
print("ErrorMessageOrResult : ", errorMessageOrResult)
print("Response : ", response)

RequestAsync

Sends an HTTP request using any method with the provided dictionary of information.

Parameters

Value InRequestOptions

Return

Value

Code Samples

UrlEncode

The UrlEncode function takes a string reference as input and returns the URL-encoded version of that string.

Parameters

string InInput

Return

string

Code Samples

local HttpService = game:GetService("HttpService")

local Query = "Hello #OVERDARE#"
local Encoded = HttpService:UrlEncode(Query)

print(Encoded)

Events

Last updated