Topic by Hariharan J
Content
I am trying to get a list of contacts from our OSvC instance using the Connect REST API for contacts object. The REST endpoint works flawlessly using SOAPUI and also when I execute it using the browser (Chrome and Firefox) directly. However when I try to use endpoint in JavaScript using a simple HTML form, the response HTTP 401 is returned.
I'm passing the 'Authorization' header in the code for a get, but when I check the network request (in Chrome Developer tools), the header is missing! Morever this same code works if I use method JSONP instead of GET.
My whole intent is to overcome the CORS error since JS code is being run from a domain that is currently not allowed by OSvC.
So my question is as follows
1) Is there any setting on OSvC (Site Configuration etc) that allows it to accept REST calls from Cross origin?
2) Alternately, is there something that I can modify in a controller file to enable Cross-Origin Resource Sharing (CORS)
3) Why does a browser 'GET'/''JSONP' work while same request through Javascript fails?
I am attaching the sample code from OSvC Developer Tools youtube video that should work, but doesn't
Looking forward to your inputs
Regards,
Hariharan