R-language for Uploading Documents in Rossum API

This R code shows how to upload a document automatically using Rossum API to a particular Rossum queue.

This R example demonstrates how to upload a document using Rossum API to a particular Rossum queue. Set the options at the beginning of the code – they store your credentials, and also the identifier of the queue to upload in. You can find out the queue id by looking at your main screen URL, it is the number 12345 in https://elis.rossum.ai/annotations/12345.

See the reference API documentation for more details about how to use the upload API.

library("httr")

username <- "[email protected]"
password <- "yourpassword"
queue_id <- 12345
login_url <- "https://api.elis.rossum.ai/v1/auth/login"
queue_url <- paste("https://api.elis.rossum.ai/v1/queues/", queue_id, "/upload", sep = "")
filepath = "path/to/file"

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 <- POST(
  queue_url,
  add_headers(
    "Authorization" = token,
    "Content-Disposition" = paste("attachment; filename=", basename(filepath), sep="")
  ),
  body = upload_file(filepath)
)