'Upload .qsf to Qualtrics using httr

I'm trying to figure out how to mimic this python code that uploads a Qualtrics survey format (.qsf) file to the server using the R package httr. This is one of my attempts:

headers = c(
  "X-API-TOKEN" = Sys.getenv('QUALTRICS_API_KEY')
)

result = httr::POST(
  url = stringr::str_glue(
    'https://{base_url}/API/v3/surveys',
    base_url = Sys.getenv('QUALTRICS_BASE_URL')
  ),
  config = httr::add_headers(headers),
  body = httr::upload_file(
    here::here('path/to/survey.qsf'), 
    type = 'application/vnd.qualtrics.survey.qsf'
  ),
  data = list('name' = 'uploaded_from_qsf'),
  encode = 'multipart'
)

The resulting message is pretty generic:

enter image description here

I have checked the environment variables, URL, and path to file. These seem fine based off other API calls I have performed.

I would also be happy with a solution that involves uploading the .qsf from GitHub.

Thank you!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source