Hi @apitiot and @dvbridges,
Because of the way a number of people have set up our study together, I’m trying to use responses previously recorded in qualtrics to change parts of an online task in psychoJs (3.2.4).
The request to their api is a straightforward get
, and I’m having success with curl and python to grab the responses that I want, but when I try to adapt this jquery ajax solution to hit the qualtrics domain instead of pavlovia, I’m running into CORS permissions issues. For example, running from the console after piloting the task to try to grab the json responses, I do:
url = `https://qualtrics.com/API/v3/surveys/${survey_id}/responses/${response_id}`
headers = {'accept': 'application/json', 'x-api-token': token}
$.ajax({url: url, headers: headers}).done(successFunction);
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource. (Reason: CORS request did not succeed).
I’ve done a little bit of work setting CORS headers, but would appreciate a little help here. From my understanding, it’s the CORS header that’s blocking on the xhr server, e.g. qualtrics.com/API/v3
, right? Or is it the case that I need to set the permission header on the request from pavlovia, e.g. in the header of the html sent from pavlovia? I can’t imagine I’m the first person trying to use this API from a client browser, right?
Is this something that I can change with pavlovia settings? Or should I bother the qualtrics help desk with this one? I did find this jQuery example directly on their site, but there’s no mention of CORS.
I’m trying to avoid uploading responses in a csv/tsv and changing the actual psychojs repository every time. Can you think of a better solution? Thanks!!