API to export survey definition | XM Community
Question

API to export survey definition


Badge +1

Hi folks,

Experienced developer here. I’m trying to automate the release management (continuous deployment) of our surveys in our Qualtrics tenant. I understand there is documentation around the importing of a survey definition (qsf ) file, but I cannot find any guidance/post in the QX community about exporting a qsf file through an API.

Using Chrome’s dev tools, I’ve been able to identify the API endpoint located at …

https://<>.az1.qualtrics.com/Q/EditSection/Post/ExportSurvey?SurveyID=<>

... to perform this export but it doesn’t seem to accept the “X-API-token” in the request header as a means of authorization (as other publicly-documented QX APIs successfully accept).

Questions:

  1. Does anyone have any solution to address this problem?
  2. Are there any plans on making this API publicly documented like the related importSurvey API? (and not force our deployment-automation process to use something like Selenium to generate a UDSSessionID [of a user] to be used in the httpRequest’s cookie?)

Thanks for reading and I must say that having this problem resolved would be a HUGE help to making this overall platform more CI/CD-friendly.

marko


2 replies

Userlevel 6
Badge +27

Since such API is not avialable on Qualtrics API page, we can follow the steps mentioned here to raise this as a product idea.

Userlevel 5
Badge +13

Hey markogotovac,

😀 The following API would get you what you need with a small amount of parsing:

https://api.qualtrics.com/9d0928392673d-get-survey

For me I am using Python to query this API, so I use a function like the following to retrieve the survey template data:

def GetSurveyDefinition(strSurveyId, strApiToken):
    url = _CONFIG_["QAPI_ROOTURL"]+"survey-definitions/"+strSurveyId+"?format=qsf"

    headers = {
        "Content-Type": "application/json",
        "X-API-TOKEN": strApiToken
    }
    response = requests.request("GET", url, headers=headers)
    jsonResponse = json.loads(response.text)    # convert the text JSON to a JSON object
    print("export status: ",jsonResponse['meta']['httpStatus'])
    return jsonResponse



surveyTemplate = GetSurveyDefinition(strSurveyId, _CONFIG_["QAPI_TOKEN"])

with open(_CONFIG_["DOCKER_MOUNT_DIR"]+"/data/"+strSurveyId+".qsf", mode='w') as jsonFile:
        jsonFile.write(json.dumps(surveyTemplate["result"], indent=2))

The important thing is that you only want the `surveyTemplate["result"]` to use as your survey template file contents.

 

Leave a Reply