How to call Rest APIs URLS from service-now from client appliaction using Angularjs

saran3
Kilo Contributor

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....

6 REPLIES 6

ChrisBurks
Mega Sage

You would need to use a Processor to be able to set your ServiceNow instance to support CORS (cross origin resource sharing). Within the processor you would need to create a custom API to gather the desired information.



Add HTTP-header on CMS


silas1
ServiceNow Employee
ServiceNow Employee

Just a heads up, the REST API framework in SN will support CORS in a release coming very soon, so this use case will be supported in a better way.


saran3
Kilo Contributor

Hi All,


        Thanks for your prompt advice and support on this,May i have way to implement the RestAPI URL using Processors with examples if any body has done this before.(particularly how to implement it in scripted based Processors).



Thanks & Regards,


Saran


Hi Saran,



If you follow the link in my previous post there is a link provided with an example on how to create an API within ServiceNow using a processor script.



Or just click the link here:



Create your own REST-based ServiceNow Web Service-John Andersen