I have been trying to do a post in Service Now through an angularjs form in SP, however I am always getting a CORS error. I've taken all CORS rules from Service Now and still am getting this error and started to think that it might be SP...

This is my header:

   method: "POST",
   url: "https://mycompany.service-now.com/api/now/table/u_application_request",
   data: JSON.stringify(requestItem),
   withCredentials: true,
   headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded',
        'Authorization': 'Basic ' + encoded,
        'Allow-Control-Access-Origin': 'https://myCompany.sharepoint.com'

And I keep getting this response:

Failed to load https://myCompany.service-now.com/api/now/table/u_application_request: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://myCompany.sharepoint.com' is therefore not allowed access.
angular.js:14525 Possibly unhandled rejection: {"data":null,"status":-1,"config":{"method":"POST","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","url":"https://myCompany.service-now.com/api/now/table/u_application_request","data":"{\"u_short_description\":\"hiqhi\",\"sys_created_by\":14,\"u_state\":\"Functionality Requests\",\"u_description\":\"hi\",\"u_configuration_item\":\"Browser: Chrome. Version: 65. OS: Windows. Plugins: Chrome PDF Plugin/ Chrome PDF Viewer/ Native Client/ Widevine Content Decryption Module/ \",\"u_work_notes\":\"https://myCompany.sharepoint.com/sites/MySite\"}","withCredentials":true,"headers":{"Accept":"application/json","Content-Type":"application/x-www-form-urlencoded","Authorization":"Basic U05CcDDSAWE1ZXN0S4NQOgNOU1WernRyQ2JhdTYwTg=="}},"statusText":""}
(anonymous) @ angular.js:14525
(anonymous) @ angular.js:11008
g @ angular.js:16860
$digest @ angular.js:17971
$apply @ angular.js:18269
l @ angular.js:12387
e @ angular.js:12551
error (async)
(anonymous) @ angular.js:12554
p @ angular.js:12332
(anonymous) @ angular.js:12084
(anonymous) @ angular.js:16832
$digest @ angular.js:17971
$apply @ angular.js:18269
l @ angular.js:12387
A.onload @ angular.js:12541
load (async)
(anonymous) @ angular.js:12524
p @ angular.js:12332
(anonymous) @ angular.js:12084
(anonymous) @ angular.js:16832
$digest @ angular.js:17971
$apply @ angular.js:18269
(anonymous) @ angular.js:26999
hg @ angular.js:3734
d @ angular.js:3722
angular.js:12587 XHR finished loading: OPTIONS "https://myCompany.service-now.com/api/now/table/u_application_request".

For what I notice at the end, it does load the SNOW site, but does not perform the POST method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.