Response Import API - CSV Upload Error | XM Community
Solved

Response Import API - CSV Upload Error

  • 26 April 2023
  • 3 replies
  • 182 views

Userlevel 7
Badge +36

Hello Community,

I did found various posts around it but none of it has been answered:

Has anyone able to successfully import a response via Response Import API, from a CSV file? Through either webservice task or Postman or any other platform.

If yes, can you please list down detailed steps of your approach or a QSF file would be great.

It would be of great help!

 

icon

Best answer by Shashi 26 April 2023, 15:09

View original

3 replies

Userlevel 6
Badge +27

Are you trying to upload csv from local mochine?

Userlevel 7
Badge +36

Yes, from a local machine 

Userlevel 6
Badge +27

I got that working using below Python code.

Upload API:

import requests
import json

url = 'https://fra1.qualtrics.com/API/v3/surveys/SV_XXXX/import-responses'
headers = {
'Content-Type': 'text/csv',
'charset': 'UTF-8',
'X-API-TOKEN': 'XXXX'
}
with open('upload.csv', 'rb') as file:
response = requests.post(url, headers=headers, data=file)

print(response.text)

Progress API

import requests

url = "https://fra1.qualtrics.com/API/v3/surveys/SV_XXXX/import-responses/<Progress ID>"

headers = {
"Content-Type": "application/json",
"X-API-TOKEN": "XXXX"
}

response = requests.request("GET", url, headers=headers)

print(response.text)

Make sure to use correct datacenter id as this API won’t work in proxy request. We can also combine both the code and check the progress at a fixed interval.

Leave a Reply