How to call Rest APIs(Table API) of service-now from client appliaction using Angularjs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2015 03:11 AM
I need a help about how to access service now tables to be accessed by inbound restapi url to be called at C#.net based client application to retrieve,create,update and retrieve records using ANGULARJS.
I have issue while accessing the REST URL for the table created on my service now instance and i tried to consume that URL to make call from .net client application using angularJS for CRUD operation.it would be great that any one made a call from client application to Service now before then kindly help me out to resolve this, where i had tried to made call from ay application it shows a error as "XMLHttpRequest cannot load http://xxxxx.service-now.com/api/now/table/<tablename>. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:55734' is therefore not allowed access." though i made recommended changes on request header as follows,which recommended for resolving this on many posts,
$http.defaults.headers.common['Access-Control-Allow-Origin'] = "*";
$http.defaults.headers.common['Access-Control-Allow-Headers'] = "X-Requested-With";
and also How to achieve or enable CORS(cross origin Resource sharing ),to make sure that client applications to access the rest apis without an isssue.
Kindly help on this post....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2015 12:28 AM
Hi Saran,
I also tried making rest calls from angular client application to the instance. even if you include
$http.defaults.headers.common['Access-Control-Allow-Origin'] = "*";
$http.defaults.headers.common['Access-Control-Allow-Headers'] = "X-Requested-With";
lines in your client application, server has to respond with Access-Control-Allow-Origin = "*"; or your client name Access-Control-Allow-Origin = "localhost:9000";
if it does not respond with that during OPTION response i dont think you can access instance.
see below screenshot.
Sever responds with Allow:GET,HEAD,etc but it does not respond with Allow-origin.
I guess service now doesn't support CORS.
i hope it helps.
Regards,
Rushit Patel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2015 05:15 AM
Hi Rushit,
Thanks for the information,i just heard about we can achieve the same by using custom processors .
Thanks,
Saran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2017 08:55 PM
ServiceNow supports CORS for the REST APIs, including the Table API and scripted REST web services. Other web service APIs, such as the SOAP API, do not support CORS.