How to use API in R (without using packages such as qualtRics) | XM Community
Solved

How to use API in R (without using packages such as qualtRics)

  • 3 June 2019
  • 1 reply
  • 8 views

Userlevel 1
Badge +6
Hi
I used to use API v2 for some tasks with our contacts. Now I'm not sure how I should construct my calls in R after they upgraded to v3, the 'Try' button on their API page isn't even working.
Any help would be greatly appreciated.
-Helgi
icon

Best answer by Helgi 7 June 2019, 15:14

View original

1 reply

Userlevel 1
Badge +6
I found the answer. If anyone is also in trouble, here is the answer:
https://cran.r-project.org/web/packages/curl/vignettes/intro.html#customizing_requests

library(curl)
library(jsonlite)
h <- new_handle()
handle_setheaders(h,
"X-API-TOKEN" = "my_token"
)
req <- curl_fetch_memory("https://yourdatacenterid.qualtrics.com/API/v3/users", handle = h)
jsonlite::prettify(rawToChar(req$content))

Leave a Reply