function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
lakshmi.sf9lakshmi.sf9 

REST API - CORS Error

Hi,

I am doing the integration between salesforce to UI (Jquery). When I hit the url in web browser and send the call out to salesforce I am getting the below error.
https://xxxxxxxxxxxxx/services/apexrest/CreateCase. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://xxxxxxxxxxxxx' is therefore not allowed access. The response had HTTP status code 401.
In salesforce I added the url in remote site settings and in CORS whie list.
From UI part in Jquery enabled cors. From SOAP UI Toll I was able to send call out and get the response.
But from original server I am facing the above error.
Is there any settings missed in salesforce or jquery.

This is critical to me. Please any one suggest me.

I appreciate the help to resolve this issue.

Thanks in advance,
Lakshmi

 

 

@Karanraj@Karanraj
By seeing the error message seems like the browser is blocking the request as it usually allows a request in the same origin for security reasons. Try out the below approaches in the jquery code which might be helpful for you 

1.  https://jvaneyck.wordpress.com/2014/01/07/cross-domain-requests-in-javascript/
2. http://www.html5rocks.com/en/tutorials/cors/

Check this blog post which helps to create the jQuery application with the salesforce REST API https://developer.salesforce.com/blogs/developer-relations/2015/08/creating-jquery-application-using-rest-api.html You can try the above approaches to avoid the CROS error