I cant send a http request when doing a local secrets playtest

Hi, so i tried using secrets, and wanted to access google’s “generative” API.

And when i do a playtest, i get an error, saying “400 (Bad Request)”. Pretty standard.
image

i think there’s nothing wrong with my code, i was setting up the Secrets Locally, correctly as it should.

Heres the json

{"google": ["___", "*" ]}

When i printed the secrets, it looked like this:
image

heres my code:

local HttpService = game.HttpService
local apiKey = HttpService:GetSecret("google")

local baseUrl = "https://generativelanguage.googleapis.com/v1beta/models?key="

local urlWithApi = apiKey:AddPrefix(baseUrl)
print(urlWithApi)
HttpService:GetAsync(urlWithApi)

Edit: I have READ the entire documentation, and STILL have the same problem. PLEASE do not send me the Secrets Documentation, as a solution to this problem.

im pretty sure you have to format it as a .json or something inside of studio

i have done that as in that screenshot does…

image

try this

HttpService:JSONDecode(urlWithApi)

do you know how Secrets in HttpService works?
Well… if i tried that, that obviously fails…

because its a Secrets Object, and HttpService:JSONDecode is obviously for strings…

Anyways… As you wish:

local HttpService = game.HttpService
local apiKey = HttpService:GetSecret("google")

local baseUrl = "https://generativelanguage.googleapis.com/v1beta/models?key="

local urlWithApi = apiKey:AddPrefix(baseUrl)
urlWithApi = HttpService:JSONDecode(urlWithApi)
local res = HttpService:GetAsync(urlWithApi)

print(res)

image

After some research, i tried using HttpService:RequestAsync, and it gave me some details.
image

It seems like the problem wasnt me, it was rather, roblox itself…
i think that the string itself was passed like this:
image

im stupid, for not reading this: Getting Secret in Studio triggers error: Header "..." has unallowed character - #2 by zipcatmax

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.