Skip to content
Advertisement

403 Forbidden error when getting cat images

I just finished programming a dog photo program, and after a few issues it works fine. I decided to make a modified version that uses a different api to give cat images instead. It took a second to figure out but after changing the format, I get this error: urllib.error.HTTPError: HTTP Error 403: Forbidden

This error is consistent and happens every single time.

Here’s my entire code, since none of these answers seemed to help.

JavaScript

And heres the full error:

JavaScript

I tried adding an api key, and I still get the same error. Then tried adding it to the header, same story.

Since none of these answers are working, I added my entire code. Hopefully this helps.

Advertisement

Answer

The “thecatapi” needs an API Key and it seems like you aren’t providing one and that’s the reason you’re getting the 403 error

Try adding an API Key as Request Header
You can get one on the thecatapi website

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement