Skip to contents

Retrieves an item and its metadata from ScienceBase based on its unique ID. Errors if the requested item ID does not exist or access is restricted due to permissions.

Usage

item_get(sb_id, ...)

Arguments

sb_id

An sbitem object or a character ScienceBase ID corresponding to the item

...

Additional parameters are passed on to GET, POST, HEAD, PUT.

Value

An object of class sbitem

Examples

# \donttest{
# Get an item
item_get("4f4e4b24e4b07f02db6aea14")
#> Request failed [404]. Retrying in 1.2 seconds...
#> Request failed [404]. Retrying in 2 seconds...
#> Warning: Sciencebase returned '404' -- item doesn't exist or is secured
#> Request failed [404]. Retrying in 1 seconds...
#> Request failed [404]. Retrying in 1.8 seconds...
#> Warning: Sciencebase returned '404' -- item doesn't exist or is secured
#> NULL

# Search for item IDs, then pass to item_get
library("httr")
res <- query_items(list(s = "Search", q = "water", format = "json"))

if(inherits(res, "response") && res$status != 404) {
  ids <- vapply(httr::content(res)$items, "[[", "", "id")
  lapply(ids[1:3], item_get)
}
#> [[1]]
#> <ScienceBase Item> 
#>   Title: H.S.P. #Water Well Water Well
#>   Creator/LastUpdatedBy:      / 
#>   Provenance (Created / Updated):  2020-03-18T17:05:02Z / 2020-03-18T17:05:02Z
#>   Children: FALSE
#>   Item ID: 5e7254bee4b01d50926a6c66
#>   Parent ID: 4f4e49cbe4b07f02db5d8760
#> 
#> [[2]]
#> <ScienceBase Item> 
#>   Title: Water
#>   Creator/LastUpdatedBy:      / 
#>   Provenance (Created / Updated):  2016-09-29T15:16:41Z / 2018-06-18T11:56:09Z
#>   Children: FALSE
#>   Item ID: 57ed3059e4b090825011d461
#>   Parent ID: 57ed2fa1e4b090825011d45b
#> 
#> [[3]]
#> <ScienceBase Item> 
#>   Title: H.S.P. #Water well Water well
#>   Creator/LastUpdatedBy:      / 
#>   Provenance (Created / Updated):  2020-03-18T17:21:46Z / 2020-03-18T17:21:46Z
#>   Children: FALSE
#>   Item ID: 5e7258aae4b01d50926aaf76
#>   Parent ID: 4f4e49cbe4b07f02db5d8760
#> 

# }