Skip to content

Instantly share code, notes, and snippets.

@jpatrickdill
Created June 5, 2020 01:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpatrickdill/d56ee4d6d5b706d290e906a5898be753 to your computer and use it in GitHub Desktop.
Save jpatrickdill/d56ee4d6d5b706d290e906a5898be753 to your computer and use it in GitHub Desktop.
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