Why I can't use object and array for Https headers?

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

You probably should check this out HttpService | Roblox Creator Documentation

Dunno if it will fix the issue, but it’s worth a try

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

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)

no, Didn’t you try before posting this?

I haven’t try it before, that’s why I asked if it works for you