Received 200 status code when running in REST API Explorer but 401 error code in Python

Kevin Nguyen
Kilo Explorer

Hello ServiceNow community,

I'm having an issue when running APIs from ServiceNow UI:

1. I tested API with UI -> System Web Services -> REST API Explorer and it returns status code 200.

2. But when I used the code sample from UI (Python) and inputted to ATOM to run (already changed username and password), I received error code 401 although I had the necessary roles for my account.

Please help me with this issue.

Thank you.

Best Regards.

12 REPLIES 12

Hi Hitoshi,

Yes I tried this also but no matter how many times I inputted username and password and press Enter, that window keeps showing up again and again.

Furthermore, that username and password were the ones I used to log in service now instance.

That implies the ServiceNow API can't be used in the instance. Maybe it's blocked in the firewall.

It may be because it admin felt it was a security risk. Would have to ask the admin of your instance.

If the instance is using SSO, it may be blocking basic authentication.

Anyways, it's not a problem with the script but with the API restriction in the environment.