@brianj iterate_with_offset
only works for numeric-based pagination.
skipToken doesn’t just a page number, the skipToken is passed as a query parameter in each request after the first one. skipToken
is a string: The value is provided by the API and you simply need to pass it in subsequent requests as a query parameter. The loop continues until skipToken
becomes NULL
, indicating there are no more pages of results to fetch.
Hope it help you
Thanks, Nam. I ended up writing my own function for the next_req argument in httr2::req_perform_iterative(). So overall, it looks something like this:
library(tidyverse)
library(httr2)
# Build Request
req <- request("https://yul1.qualtrics.com/API/v3") %>%
req_url_path_append("directories/`my_directoryId`/mailinglists") %>%
req_headers(`X-API-TOKEN` = Sys.getenv("QUALTRICS_API_KEY"))
# Iterate through all pages
resps <- req_perform_iterative(
req,
next_req = function(resp, req){
url <- resp_body_json(resp)$result$nextPage
if (!is.null(url)) {
req_url(req, url)
}
},
max_reqs = Inf
)