Connect to Service Now from SharePoint Online
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2016 01:22 AM
Hi,
We are trying to connect Service now from SharePoint Online .Below are the options we tried. Any help would be appreciated!!
Option 1 : We tried using the Inbound REST API and tried to call the service now Get Incidents , but we are facing issue with cross domain(CORS).
After facing the above issue, we tried to use JSONP format to fire the query to ServiceNow and below is the Issue
Option 2: Later we tried to use the Outbound Rest api and tried below code
Is this right way of accessing the outbound Rest API from an external domain ? Is there any reference files which needs to be added to java script code through which browser can identify the RESTMessageV2 functions.?
Please let us know if the direction in which we are trying is right or No ?
Regards,
Nagaraju
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2016 06:29 AM
Hello Nagaraju,
In your jquery code(Option 1), you have to add Authentication information in the Headers:
headers: {
'Authorization': 'Basic '+btoa('admin'+':'+'admin')
/*other headers */
},
And make sure the user you use for authentication has rest_service role.
In Option 2, the script you are using will not work aoutside servicenow.
Instead use javascript or jquery as u did in option 1.
Javascript would be something like this:
var requestBody = "";
var client=new XMLHttpRequest();
client.open("get","https://<instancename>.service-now.com/api/now/table/incident");
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2017 02:34 AM
Hi
I am trying to do something similar and I would appreciate if someone can help here?
url: "https://myinstance.service-now.com/api/now/table/incident?sysparm_limit=1",
type: "GET",
async: false,
headers: {
"accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Basic "+btoa('user_rest'+':'+'mypassword')
},
success: function (data) {
console.log("from successs " + data);
},
error: function (error) {
console.log("failed");
console.log(JSON.stringify(error));
}
I have define the CORS rules with *.sharepoint.com and also user_rest has the rest_service and web_service admin roles. I am still recieving this error:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://mytenant.sharepoint.com' is therefore not allowed access.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2020 07:05 AM
Hi,
Is there any update on this query.
I am having the exactly same problem and getting the same error message.
My requirement is to pull data from ServiceNow and save it in SharePoint 2013 but i cannot use any third party tools.
I am preferring RestApi. Can some please suggest me the approac and resolution of the above mentioned issue(Option1)