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
Michael SpritzerMichael Spritzer 

REST API Issue

Hello, I'm looking to use the Salesforce REST api to get data from the system into a sharepoint site. We've setup the whitelisted domains in the CORS section but are still getting the "XMLHttpRequest for [URL] required Cross Origin Resource Sharing (CORS)" error.

Our sharepoint site is on our internal network and I was wondering if that's why the whitelisted domain isn't working. Is there a way to get around this?

Here's the javascript call I'm using, just in case I missed something and it's actually a programming error.
 
<script>
        $(document).ready(function() {
               $.ajax({
                       url: "https://my.salesforce.com/services/data.json
               }).done(function(data) {
                       $('.output').append(data);
                }).fail(function (jqXHR, textStatus) {
                         alert('error: ' + jqXHR);
                         });
          });
</script>


Thanks!
SandhyaSandhya (Salesforce Developers) 
Hi Michael Spritzer,

When I was researching about this error, i found that this error occurs with internet explorer.Please refer below links.

http://stackoverflow.com/questions/20160003/xmlhttprequest-for-http-required-cross-origin-resource-sharing-cors-and-pre
 
http://stackoverflow.com/questions/24646732/sec7118-xmlhttprequest-cors-ie-console-message
 
https://developer.salesforce.com/forums/?id=906F0000000BI96IAG
 
Hope this helps you!

If this helps you mark it as solved.

Thanks and Regards
Sandhya

 
Michael SpritzerMichael Spritzer
I tried again in Google Chrome and am getting a similar error:
XMLHttpRequest cannot load https://my.salesforce.com/services/oauth2/token. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'myorigin.com' is therefore not allowed access.

Also, I tried using the code locally outside of sharepoint and it works fine, it just fails on the company sharepoint site.
JustAGirlyGeekJustAGirlyGeek
Hi Michael,

Did you ever get this to work? We have a similar situation since our SharePoint instance not exposed to the Internet.

Thanks!