You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use zotero_api::{Zotero,ZoteroApi,ZoteroApiExecutor};use zotero_data::item::{BookData,BookDataBuilder,Creator,CreatorBuilder};let z = Zotero::set_user("123456789","bZARysJ579K5SdmYuaAJ");let creators :Vec<Creator> = vec![CreatorBuilder::default().creator_type("author").first_name("John").last_name("Doe").build().unwrap()];let new_book :BookData = BookDataBuilder::default().title("Sample_2").creators(creators).item_type("book").build().unwrap();let _:Result<(),_> = z.create_new_item(new_book).execute(&z);
Updating items and collections
use zotero_api::{Zotero,ZoteroApi,ZoteroApiExecutor};use zotero_data::item::ItemType;let z = Zotero::set_user("123456789","bZARysJ579K5SdmYuaAJ");let item:Result<ItemType,_> = z.get_item("Q8GNE36F",None).execute(&z);ifletOk(mut result) = item {ifletItemType::Book(bookdata) = &mut result {
bookdata.title = "A new title".to_string();
bookdata.publisher = "A new publisher".to_string();let _:Result<(),_> =z.update_item(&bookdata.key,&bookdata).execute(&z);};println!("{:?}", serde_json::to_string(&result));};
Async Support
use zotero_api::{Zotero,ZoteroApi,ZoteroApiAsyncExecutor};use zotero_data::Item;let z = Zotero::set_user("123456789","bZARysJ579K5SdmYuaAJ");let item_result:Result<Item,_> = z.get_item("Q8GNE36F",None).execute(&z).await;println!("{item_result:#?}")