error 401 unauthorized on api call

SheilaFieni

New member
trying to fetch data from a public api and getting a 401 unauthorized. do i need to pass the api key in the header or the url?
 
hey, for a 401 it's almost always in the header. most APIs, even public ones, use an `Authorization: Bearer YOUR_API_KEY` header or sometimes a custom `X-API-Key`. putting it directly in the URL query string is less common for authentication these days, and generally not as secure. def check the API's docs though, they'll specify exactly how they want it.
 
hey, for a 401 it's almost always in the header. most APIs, even public ones, use an `Authorization: Bearer YOUR_API_KEY` header or sometimes a custom `X-API-Key`. putting it directly in the URL query string is less common for authentication these days, and generally not as secure. def check the API's docs though, they'll specify exactly how they want it.

that's super helpful thanks
 
Back
Top