Received 200 status code when running in REST API Explorer but 401 error code in Python
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2022 08:55 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2022 03:58 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2022 05:51 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2022 05:56 PM
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.