Solved
Exporting survey responses using Google Apps Scripts
I am trying to export survey responses using Google Apps Scripts using the POST API. I know I am pinging an address, but it comes back with
httpStatus":"400 - Bad Request".
My code works theoretically, but I believe its calling incorrectly and I am not sure why.
var option = {
async: true,
crossDomain: true,
url:"https://ousurvey.ca1.qualtrics.com/API/v3/surveys/SV_8dK8AKUFyAH8qyN/export-responses/",
method: "POST",
"headers": {
"X-API-TOKEN": "",
"Content-Type": "application/json",
"cache-control": "no-cache",
"Postman-Token": ""
},
processData: false,
data : '{"format":"csv"}',
muteHttpExceptions: true
};
var qUrl='https://ousurvey.ca1.qualtrics.com/API/v3/surveys/SV_8dK8AKUFyAH8qyN/export-responses/'
var getSurvey = UrlFetchApp.fetch(qUrl, option);
Currently I am just trying to pull the responses from a test survey I made, but have had no luck. I can get the two GET APIs to work by obtaining the IDs using POSTMAN, but the POST is being stubborn. I feel like I am missing something very obvious but I can't make any connections.
Best answer by jeNguyen
I was able to figure out what was wrong with it with some help. It was mainly due to my format of the call itself:
var qUrl = "https://ousurvey.ca1.qualtrics.com/API/v3/surveys/SV_dd7ZjV7L1RX5WKh/export-responses/";
var option = {
method: "post",
headers: {"X-API-TOKEN": "JCu7bnl5ldjN9ipobqGUZj7kLO69Hklfxbr6YT9R"},
contentType: "application/json",
payload: JSON.stringify({"format": "csv"}),
muteHttpExceptions: true,
};
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
