Skip to contents

Create or update collections and items in a specified library

Usage

ZoteroPost(
  zotero,
  post.collections = TRUE,
  post.items = TRUE,
  post.attachments = TRUE,
  post.limit = 50,
  force = FALSE,
  silent = FALSE
)

Arguments

zotero

A list with information on the specified Zotero library (e.g., id, API key, collections, and items)

post.collections

Try to copy specified collections, Default: TRUE

post.items

Try to copy specified items?, Default: TRUE

post.attachments

Try to copy specified extras (i.e., attachments and notes)?, Default: TRUE

post.limit

Number of collections/items to post per request (max 50), Default: 50

force

Force is seldom wise, but sometimes..., Default: FALSE

silent

c2z is noisy, tell it to be quiet, Default: FALSE

Value

A list with information on the specified Zotero library (e.g., posted collections and items)

Details

Please see https://oeysan.github.io/c2z/

Examples

# \donttest{
  # Connect to the public group "c2z_delete"
  # NB! This process can be done using only `Zotero` (see README)
  zotero <- Zotero(
    user = FALSE,
    id = "4988497",
    api = "RqlAmlH5l1KPghfCseAq1sQ1"
  )

  # Create a new collection for POST
  zotero$collections <- tibble::tibble(
    key = ZoteroKey(),
    version = 0,
    name = "Post-test",
    parentCollection = "FALSE"
  )

  # Add item to post using `ZoteroAdd` (and `ZoteroDoi`)
  zotero <- ZoteroAdd(
    zotero,
    doi = "10.1126/sciadv.abd1705"
  )
#> Searching 1 item using DOI 

  # Post a DOI to the public group "c2z_delete"
  post.example <- ZoteroPost(
    zotero,
    post.collections = TRUE,
    post.items = TRUE
  )
#> Adding 1 collection to library using 1 POST request 
#> 
—————————————————Process: 100.00% (1/1). Elapsed time: 00:00:00—————————————————
#> $post.status.collections
#> # A tibble: 1 × 2
#>   status  key     
#>   <fct>   <chr>   
#> 1 success 6UDRVUIZ
#> 
#> $post.summary.collections
#> # A tibble: 1 × 2
#>   status  summary
#>   <fct>     <int>
#> 1 success       1
#> 
#> 
#> Adding 1 item to library using 1 POST request 
#> 
—————————————————Process: 100.00% (1/1). Elapsed time: 00:00:00—————————————————
#> $post.status.items
#> # A tibble: 1 × 2
#>   status  key     
#>   <fct>   <chr>   
#> 1 success JPYPCS87
#> 
#> $post.summary.items
#> # A tibble: 1 × 2
#>   status  summary
#>   <fct>     <int>
#> 1 success       1
#> 
#> 

  # Delete collections and items using `ZoteroDelete`
  delete.example <- ZoteroDelete(
    post.example,
    delete.collections = TRUE,
    delete.items = TRUE
  )
#> Deleting 1 collection using 1 DELETE request 
#> 
—————————————————Process: 100.00% (1/1). Elapsed time: 00:00:00—————————————————
#> Deleting 1 item using 1 DELETE request 
#> 
—————————————————Process: 100.00% (1/1). Elapsed time: 00:00:00—————————————————

  # Print index using `ZoteroIndex`
  if (any(nrow(post.example$items))) {
    ZoteroIndex(post.example$items) |>
      dplyr::select(name) |>
      print(width = 80)
  }
#> # A tibble: 1 × 1
#>   name                                                                          
#>   <chr>                                                                         
#> 1 Serra-Garcia & Gneezy (2021) Nonreplicable publications are cited more than r…
# }