xccosanxcc
(xccosanxcc)
January 13, 2022, 6:01pm
#1
code:
local headers = {types={["test"]=true,["test2"]=true}}
print("test0",headers)
local success,data = pcall(Http.GetAsync,Http,URL,false,headers)
print("test1",success,data)
output:
test1 false Header “types” must have its value be a string!
I tried sending some information with array or object but it didn’t work
I can’t use object and array, Why? (I already tested on arrays)
i mean, what is the reason, and how can i solve it
It is how http requests work, you can’t do it with objects, you can convert them into a string, then parse them on the other side.
Also, I believe you are using HTTP wrong. Read more here: HttpService | Roblox Creator Documentation
1 Like
z_MiTeX
(mitex)
January 13, 2022, 6:21pm
#3
You probably should check this out HttpService | Roblox Creator Documentation
Dunno if it will fix the issue, but it’s worth a try
xccosanxcc
(xccosanxcc)
January 13, 2022, 7:52pm
#5
can you give example?
I tried many ways and none of them worked
local data = {test={hi="hello",testing="true",testcount=123,"Testing..."}}
-- data(lua table) = {test={[1]="Testing...",["hi"]="hello",["testing"]="true",["testcount"]=123}}
data = HttpService:JSONEncode(data)
print(data) -- ["Testing..."]
print(type(data)) -- string
z_MiTeX
(mitex)
January 14, 2022, 11:10am
#6
I mean as you said, the dictionary has to be a string which can be done by encoding the dictionary
Does this work for you?
local data = {test={hi="hello",testing="true",testcount=123,"Testing..."}}
-- data(lua table) = {test={[1]="Testing...",["hi"]="hello",["testing"]="true",["testcount"]=123}}
data = HttpService:JSONEncode(data)
print(data) -- ["Testing..."]
print(type(data)) -- string
local headers = {types={["test"]=true,["test2"]=true}}
print("test0",headers)
local success,data = pcall(Http.GetAsync,Http,URL,false,data)
print("test1",success,data)
xccosanxcc
(xccosanxcc)
January 14, 2022, 7:22pm
#7
no, Didn’t you try before posting this?
z_MiTeX
(mitex)
January 14, 2022, 11:04pm
#8
I haven’t try it before, that’s why I asked if it works for you