How to access Qualtrics API in custom code section | XM Community
Skip to main content

I’m trying to use the Qualtrics API in a custom code block in a survey workflow.

But it complains about the import statement when I include it and complains it doesn’t recognise the api call if I leave it out.

I can’t find an answer on how to call the API here. I contacted Qualtrics technical support but they also don’t know. They said someone here might know.

import Qualtrics from "Qualtrics";
function codeTask() {
Qualtrics.SurveyEngine.setEmbeddedData("a", "b");
}

Thanks

Hi,

I’m not sure what you’re trying to achieve, but you seem to be confusing the question API, Qualtrics API and code tasks.

Anyhow, you can’t call any API from a code task, use a web service task to make your call to the API you need.

If you’re trying to use the question API, that must be done in the custom javascript section of one of your survey’s questions.


Hi ​@tHisUsERnAmEaLReAdYExiStS ,

it's not possible to call external or Qualtrics APIs directly from the Code Task in a Qualtrics Workflow.

The Code Task in Qualtrics Workflows is designed strictly for data man manipulation, transformation and formatting — not for making network requests or calling APIs. 

If you need to call an API (e.g., to get or send data), you should:

  1. Use a Web Service Task to call the API. https://api.qualtrics.com/0f8fac59d1995-api-reference
  2. Then use a Code Task after that to manipulate or format the API response. https://www.qualtrics.com/support/survey-platform/actions-module/code-task/

Thank you


I understand now. Thank you both for your explanation. I was trying to strip some identifying info from some embedded data. I’m now only doing this in the code block and updating the embedded data later on in a web service block.


Leave a Reply