User Not Authenticated error when accessing the Rest table api.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2018 09:12 AM
Hi,
I am getting below error when trying to access the Servicenow rest api.
401{"error":{"message":"User Not Authenticated","detail":"Required to provide Auth information"},"status":"failure"}
Below is the java script code by which I want to access the rest api.
<script type = "text/javascript">
function CallServicenow()
{
var requestBody = "";
var client=new XMLHttpRequest();
client.open("get","https://*****.service-now.com/api/now/table/incident?sysparm_limit=1");
client.setRequestHeader('Accept','application/json');
client.setRequestHeader('Content-Type','application/json');
//Eg. UserName="admin", Password="admin" for this code sample.
client.setRequestHeader('Authorization', 'Basic '+btoa('admin'+':'+'admin'));
client.onreadystatechange = function() {
if(this.readyState == this.DONE) {
document.getElementById("response").innerHTML=this.status + this.response;
}
};
client.send(requestBody);
}
</script>
Below are the role assigned to this user.
admin
itil
personalize_dictionary
rest_api_explorer
rest_service
security_admin
snc_internal
web_service_admin
If I directly access the below url then it works. but not working when trying to access using script.
https://*****.service-now.com/api/now/table/incident?sysparm_limit=1
- Labels:
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2018 09:23 AM
adding one thread here.. can you try this way.. just to validate if it's related to authentication issue or something else.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2018 11:02 AM
Hi Harshvardhan,
I tested it with Servicenow Script and it's working fine. But Java script and python script is not working and sending the below error :
401{"error":{"message":"User Not Authenticated","detail":"Required to provide Auth information"},"status":"failure"}
Any suggestion please..
thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2018 09:18 PM
adding one article here.kindly refer that.
also have you defined the "CORS" rule? if not then kindly define and try again.
https://hi.service-now.com/kb_view.do?sysparm_article=KB0565021