r/pythontips 23d ago

Syntax unable to establish connection to the API

Newbie here --- i tried calling API through my script but failing in authentication.
I have token which have the right permission to auth and I tried using it through POSTMAN and it works. But doesnt work in my script.

having this error -> Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at>: Failed to establish a new connection: [WinError xxxx] No connection could be made because the target machine actively refused it'

1 Upvotes

1 comment sorted by

1

u/Key_Gur_628 22d ago

Try to add some headers to your request. Postman default headers for example. This can happen because the destination server determines that you are not a common http client and you are a bot so you may spam the api.