Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How come my request returns Invalid_Api_Key? Simple HTTPS

Asked by 5 years ago
local HttpService = game:GetService("HttpService")
local url = "https://fortnite-public-api.theapinetwork.com/prod09/upcoming/get"
local api = {['Key']="5515aff128c1280bc37c6080265619bd"}
local response = HttpService:GetAsync(url,false,api)


local data = HttpService:JSONDecode(response)
for _,v in pairs(data) do
    print (v)
end

Its attempting to decode the 'url' and parse it.

The API Key is brand new, and i've tried this using multiple keys, none working.

1 answer

Log in to vote
0
Answered by
ozzyDrive 670 Moderation Voter
5 years ago

Looking at the documentation, the API is expecting you to make a POST request with the Authorization token as a header. You're attempting to make a GET request with some "Key" header.

local authHeader = "Authorization: yourAPIKey"
local response = HttpService:PostAsync(url, "", Enum.HttpContentType.ApplicationJson, false, authHeader)

Also, don't post your API keys into the public. And next time when posting a question about a less-known third-party-service, please provide a link to the service and its documentation.

Ad

Answer this question