Response Import API - CSV Upload Error | XM Community
Skip to main content
Solved

Response Import API - CSV Upload Error


Deepak
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+44

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!

 

Best answer by Shashi

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.

View original

3 replies

Shashi
Level 8 ●●●●●●●●
Forum|alt.badge.img+32
  • Level 8 ●●●●●●●●
  • 633 replies
  • April 26, 2023

Are you trying to upload csv from local mochine?


Deepak
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+44
  • Author
  • 1549 replies
  • April 26, 2023

Yes, from a local machine 


Shashi
Level 8 ●●●●●●●●
Forum|alt.badge.img+32
  • Level 8 ●●●●●●●●
  • 633 replies
  • Answer
  • April 26, 2023

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