Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
local url_query = {arg1="val1", arg2="val2"}
local post_json = {a=1, b=2, this="is json"}
local HttpService = game:GetService("HttpService")
local options = {
Url = ("https://httpbin.org/post?%s=%s&%s=%s"):format("arg1", url_query.arg1, "arg2", url_query.arg2),
Method = "POST",
Headers = {["Content-Type"] = "application/json"},
Body = HttpService:JSONEncode(post_json)
}
local r = HttpService:RequestAsync(options)
print(r.Headers["content-type"])
local data = HttpService:JSONEncode(r.Body)
local url_query = {arg1="val1", arg2="val2"}
local post_json = {a=1, b=2, this="is json"}
local http = require(ReplicatedStorage.http)
local r = http.post("https://httpbin.org/post", { query=url_query, data=post_json })
print(r.headers["content-type"])
local data = r:json()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment