Solved
Has anyone used the statistical programming language R to import survey responses with the API?
Hi all,
I have created a blank survey in Qualtrics which represents an external survey which I want to have available in Qualtrics. I have been playing with the POST function in R from the httr package. But I cannot seem to formulate the script to get an accepted status code.
The file itself has been formatted in the same way as the 'example' file was done, as suggested on this page: https://api.qualtrics.com/docs/import-responses
If anyone has done this before in R, I would appreciate a hand.
Kind regards,
Ant
Best answer by Anthony_R_CX
Hi RTSullivan, thank you for responding to my question. I have tried the 'qualtRics' package and it is amazing! Unfortunately, the current functionality is focused on downloading response from Qualtrics to R. I need to be able to post information from R into Qualtrics.
I did manage to put together a solution to my question using a combination of features within the httr package. The script below picks up a .csv file from a local directory and posts the responses to a given location.
# identify the path and file of interest
vFilePath <- paste(dir_Output, "/", vFileName, sep = "")
# Load the csv file into the Twitter Analysis Qualtrics survey
vQualtrics_Upload <- POST(url = vPOST_URL,
add_headers('X-API-TOKEN' = vQualtrics_Token),
body = list(surveyId = vQualtrics_SurveyID,
file = upload_file(vFilePath, type = "text/csv")))
# delete the csv file from local directory if successfully loaded into Qualtrics
if(vQualtrics_Upload$status_code == 200) {file.remove(vFileName)}
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
