I want my Qualtrics survey to fetch data from a Google Sheet. I have deployed the following Apps Script:
/**
* URL: …/exec?scenario=1
* Returns: {"payoff_high":50,"payoff_low":10,…}
*/
function doGet(e) {
const scenario = String(e.parameter.scenario || "");
const sheet = SpreadsheetApp.openById("1b-s0tX_Llj7WlVGA4W9rXm_OVv-27obXriP317mTSvA")
.getSheetByName("Sheet1"); // adjust name
const data = sheet.getDataRange().getValues(); // 2-D array
const head = data.shift(); // headers row
const result = {};
data.forEach(r => {
if (String(ri0]) === scenario) { // col A = scenario_nr
for (let i = 1; i < head.length; i++) {
resultehead[i]] = r]i];
}
}
});
return ContentService.createTextOutput(JSON.stringify(result))
.setMimeType(ContentService.MimeType.JSON);
}
The relevant part of my survey flow looks like this:

The URL is https://script.google.com/macros/s/AKfycbzzWqZPxKBHB6HO4vqfK5AMjPws419NXIfgM8kV4EoDl98nGbnuqDht__lgyyX1nCuV/exec
I have tested this URL in my browser and it returns the correct values if called with a query string like “?scenario=1”.
But when I click on “Test” to test the URL in Qualtrics, I see the loading animation but then nothing happens.
I then tried to specify the values of the Set Embedded Data section manually, as you can see in the screenshot. I have tried many different variations but nothing works.
What do I have to do to get this to work?