Access to XMLHttpRequest at 'https://{subdomain}.zendesk.com/api/v2/users.json' from origin '{domain name}' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. | Community
Skip to main content

Access to XMLHttpRequest at 'https://{subdomain}.zendesk.com/api/v2/users.json' from origin '{domain name}' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

  • September 30, 2019
  • 5 replies
  • 0 views

Hi,

I am getting this error:

Access to XMLHttpRequest at 'https://{subdomain}.zendesk.com/api/v2/users.json' from origin '{domain name}' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.


$.ajax({
        url: 'https://{subdomain}.zendesk.com/api/v2/users.json',
        headers: { 
        'Authorization': 'Basic ('+Base64+')',
        'Content-Type': 'application/json'//,
        },
        CORS: true,
        method: 'GET',
        })
        .done(function(data) {
        console.log(data);
        })
        .fail(function() {
        console.log('Failed!');
        });
    
 
Can you please help me find the solution for this. I have tried and followed the zendesk support articles on this but couldn't find the proper answer. 
 
Thanks  

5 replies

  • September 30, 2019

Hi Ali-

May I ask for some more information, specifically, from what context are you making this request, e.g. Zendesk app, etc?


  • Author
  • October 1, 2019

I was trying to access users.json and got this message. I think it's not possible with Basic Authentication. It needs OAuth?


  • October 1, 2019

Hi Ali-

Yes, that would be the general recommendation (of course, depending on the context). If in the context of a Zendesk app then I would recommend using the client.request() method.


  • Author
  • October 1, 2019

Hi Joseph,

Okay, is there any thread on client.request() or any example? to understand better.

Thanks 


  • October 4, 2019

Hey Ali-

This article provides a great overview of client.request().