A method to create multiple ScienceBase items with a single call and a single HTTP service request. Can be useful for improving performance of creating a large number of items at once.
Usage
items_create(parent_id = user_id(), title, ..., info = NULL)
Arguments
- parent_id
An
sbitem
object or character ScienceBase ID corresponding to the parent item (folder). This must be of length 1 or more. If length 1, then we recycle it for every item.- title
Two or more titles for the new SB items
- ...
Additional parameters are passed on to
GET
,POST
,HEAD
,PUT
.- info
(optional) list of metadata info for the new items. for each item include a named list of variables
Details
The length of the title
and info
values must be the same
length - however, the parent_id
can be of length 1 or equal to the length
of each of title
and info
parameters
Examples
if (FALSE) {
# helper function to make a random name
aname <- function() paste0(sample(letters, size = 5, replace = TRUE), collapse = "")
# Create some items - by default we use your user ID
items_create(title = c(aname(), aname()))
# add additional items in the info parameter - by default we use your user ID
items_create(title = c(aname(), aname()),
info = list(
list(contacts = list(list(name = "Suzy"))),
list(contacts = list(list(name = "Brandy")))
)
)
# another example with more information - by default we use your user ID
items_create(title = c(aname(), aname()),
info = list(
list(contacts = list(list(name = "Suzy"))),
list(contacts = list(list(name = "Brandy")))
)
)
# Pass an object of class sbitem
(x <- folder_create(user_id(), aname()))
items_create(x, title = c(aname(), aname()))
}