R-Language for Exporting Data from Rossum API
This R language code shows how to download XML data captured in a given Rossum queue for the previous calendar day.
This R language code shows how to download XML data captured in a given queue for the previous calendar day – as part of the regular export routine. Update the parameters at the beginning based on your scenario.
The export API is more powerful - you can filter by different criteria or download the data e.g. as a JSON instead - see the full docs.
This code is designed to run using the R Project language used for statistics and data science.
library("httr")
library("XML")
username <- "[email protected]"
password <- "yourpassword"
queue_id <- 12345
date_from <- Sys.Date() - 1
date_to <- Sys.Date()
login_url <- "https://example.rossum.app/api/v1/auth/login"
queue_url <- paste("https://example.rossum.app/api/v1/queues/", queue_id, "/export", sep = "")
response <- POST(
login_url,
add_headers("Content-Type" = "application/json"),
body = list("username" = username, "password" = password),
encode = "json"
)
token <- paste("token", content(response)$key)
response <- GET(
queue_url,
query = list(format = "xml", exported_at_after = date_from, exported_at_before = date_to, page_size = 100),
add_headers("Authorization" = token)
)
print(XML::xmlParse(content(response)))
This example will export at most 100 documents. To export more documents, you need to modify the code download multiple pages one by one, until it reaches the page count (or it can simply stop when an empty set of results is finally downloaded).
Updated 12 months ago