Python Script Data Export - How to include Embedded Data in the export | XM Community
Skip to main content

Python Script Data Export - How to include Embedded Data in the export

  • September 29, 2022
  • 2 replies
  • 327 views

Forum|alt.badge.img+3

When following script is used, Survey Metadata and Embedded Data fields are not being included in the export...appreciate any tips to include this data.
# Step 1: Creating Data Export
  download_request_url = base_url
  download_request_payload = '{"format":"' + file_format + '","useLabels": true ' + ',"surveyId":"' + survey_id + '"}' # you can set useLabels:True to get responses in text format
  #download_request_payload = '{"surveyMetadataIds": [] ' + ',"format":"' + file_format + ',"useLabels": true ' + ',"surveyId":"' + survey_id + '"}' # you can set useLabels:True to get responses in text format
  print(download_request_payload )
  download_request_response = requests.request("POST", download_request_url, data=download_request_payload, headers=headers)
  progress_id = download_request_response.json()["result"]["id"]
  print(download_request_response.text)

2 replies

bgooldfed
Level 4 ●●●●
Forum|alt.badge.img+25
  • Level 4 ●●●●
  • 179 replies
  • September 29, 2022

Hi nomulap,
Does your script also check the export progress and download it when it's ready? There's a general guide in the API docs here.
If you are doing this, what output are you receiving? What happens if you set the embeddedDataIds parameter in the export request?


Forum|alt.badge.img+3
  • Author
  • 2 replies
  • September 30, 2022

Hi bgooldfed
Yes, here is export progress output...
0.0
100.0
When I set embeddedDataIds parameter, it takes error...
KeyError Traceback (most recent call last)
in
1 dest_path = r"C:\\xxxxxxxxx"
2 survey_id = "xxxxxxxxxxxx"
----> 3 get_qualtrics_survey(dir_save_survey = dest_path, survey_id = survey_id)
4 print ('Done!')

in get_qualtrics_survey(dir_save_survey, survey_id)
26 print(download_request_payload )
27 download_request_response = requests.request("POST", download_request_url, data=download_request_payload, headers=headers)
---> 28 progress_id = download_request_response.json()["result"]["id"]
29 print(download_request_response.text)
30

KeyError: 'result'



Leave a Reply