CORS request not working

Not applicable

CORS request not working

I'm currently trying to retrieve and send data from Marketo's API. The problem is : my web platform is Salesforce Community. If I understand correctly this web tool, I'm not allowed to use anything else than pure javascript.

I've built a CORS request like this :

function createCORSRequest(method, url) {

  var xhr = new XMLHttpRequest();

  if ("withCredentials" in xhr) {, url, true);

  } else if (typeof XDomainRequest != "undefined") {

    xhr = new XDomainRequest();, url);

  } else {

    xhr = null;


  return xhr;


function makeCorsRequest() {

  var url = document.getElementById('url').value;

  var xhr = createCORSRequest('GET', url);

  if (!xhr) {

    alert('CORS not supported');



  xhr.onload = function() {

    var text = xhr.responseText;

    alert('Response from CORS request to ' + url + 'is : ' + text);


  xhr.onerror = function() {

    alert('Woops, there was an error making the request.');





With the help of, but the server doesn't seem to accept the request since this error comes back :

"No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://testurl…' is therefore not allowed access."

Does anyone know if Marketo's API accepts CORS requests? Or maybe have an idea that would help me solve this? Thank you very much.

Marketo Employee

Re: CORS request not working

I responded over on StackOverflow: Call Marketo API using javascript only - Stack Overflow​  There are probably other options depending on what exactly you're trying to accomplish.

Level 10 - Community Moderator

Re: CORS request not working

The REST API should never be used by directly customer-facing applications.  It's intended to be used in server-to-server contexts, preferably using bulk operations.  If you explain in full what you are actually trying to accomplish, as Kenny said, we can give you some pointers.