I'm having a problem using surveyMonkey API. I'm able to use any public method except the Crate_flow and Send_flow. these two raise me an error in the console:
OPTIONS http://api.surveymonkey.net/v2/client/create_flow?api_key=**MYAPI* 596 (596) Index.html:61 XMLHttpRequest cannot load http://api.surveymonkey.net/v2/client/create_flow?api_key=**MYAPI*. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. Index.html:61 Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://api.surveymonkey.net/v2/client/create_flow?api_key=**MYAPI*'.
the code that I'm using is this:
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://api.surveymonkey.net/v2/batch/send_flow?api_key="+MYAPI, false);
xhr.setRequestHeader('Access-Control-Allow-Origin' ,'*');
xhr.setRequestHeader('Authorization','bearer '+TOKEN);
xhr.setRequestHeader('Content-Type', 'application/json');
var body = '{"survey_id" :"54681373","collector":{"type":"email", "recipients":[{"email": "martins.nuno.santos@gmail.com", "first_name": "Nuno", "last_name": "Santos"}],"send":true}, "email_message":{"reply_email":"martins.nuno.santos@gmail.com", "subject":"YOLO", "body_text": "Vamos lá experimentar isto ! [SurveyLink], para remover carrega em [RemoveLink]"}}';
xhr.send(body);
console.log(xhr.status);
console.log(xhr.statusText);
console.log(xhr.responseText);