Write API usage examples
Please could you show the usage of the sample code as provided in the write API page. The read examples are straight forward since I only need to pad the URL details for the user and userid and define what I need to read i.e. items and all that goes in the URL and easily pasted to a browser or in code, can call up an iframe with the source URL.
I am developing in java and would need to dynamically create entries to my zotero account as a placeholder of things I need to search citations for, hence an example say on how to create a note in a given category will set me in the right path.
Thanks,
Regards,
Emma Cox
I am developing in java and would need to dynamically create entries to my zotero account as a placeholder of things I need to search citations for, hence an example say on how to create a note in a given category will set me in the right path.
Thanks,
Regards,
Emma Cox
http://www.zotero.org/support/dev/server_api/write_api
also, you can look at the existing libraries or apps developed based on the API: http://www.zotero.org/support/dev/server_api#api_implementations
My problem is how would I make use of the code snippets show in the write API page, The penny hasn't dropped yet for me on where the code is to appear.
Do I have that in the URL?
How do I define the name of the note, and if I have multiple categories, How do I create categories first. I know I will kick myself when I am shown how easy this is achieved, so preparing a nice pair of boots for that, but until then, itching to slap myself for on not seeing the obvious.
1) First you would need to do a GET request to get a template for a new item. This is returned as JSON, so you need a parser that will parse the JSON string as java objects (arrays and dictionaries).
http://www.zotero.org/support/dev/server_api/write_api#get_template_for_a_new_item
2) Then modify the object properties so that they match your note content and use the JSON library to convert the objects back to JSON string. Then POST this to the server
http://www.zotero.org/support/dev/server_api/write_api#creating_an_item
3) You will get the item id as a response. Then you need to do a third call to add that item id to a collection with another POST call
http://www.zotero.org/support/dev/server_api/write_api#adding_items_to_a_collection
Heavy lifting this appears to be for write operations, being not very clued up on programming, appears will be more reading for me.
http://www.codecademy.com/tracks/apis
but this is much more likely to be successful if you have specific questions based on existing code. Something like "how do I make a GET request in Java" is too general of a question for a limited resources listserv like Zotero's and you'd probably want to go somewhere with a deeper bench lik stackoverflow or some other general code site.
The general way the Zotero API works is no different from most other APIs.
{"result":"null<?xml version=\"1.0\"?><feed xmlns=\"http://www.w3.org/2005/Atom\" xmlns:zapi=\"http://zotero.org/ns/api\"> <title>Zotero / eomc40 / Items</title> <id>http://zotero.org/users/1269166/items/new?itemType=book</id> <link rel=\"self\" type=\"application/atom+xml\" href=\"https://api.zotero.org/users/1269166/items/new?itemType=book\"/> <link rel=\"first\" type=\"application/atom+xml\" href=\"https://api.zotero.org/users/1269166/items/new?itemType=book\"/> <link rel=\"last\" type=\"application/atom+xml\" href=\"https://api.zotero.org/users/1269166/items/new?itemType=book\"/> <link rel=\"alternate\" type=\"text/html\" href=\"http://zotero.org/users/1269166/items/new?itemType=book\"/> <zapi:totalResults>1</zapi:totalResults> <zapi:apiVersion>1</zapi:apiVersion> <updated>2013-01-29T12:50:15Z</updated> <entry xmlns:default=\"http://www.w3.org/1999/xhtml\"> <title>My Nifty Book Title</title> <author> <name>eomc40</name> <uri>http://zotero.org/eomc40</uri> </author> <id>http://zotero.org/eomc40/items/47NPQRV2</id> <published>2013-01-29T12:50:15Z</published> <updated>2013-01-29T12:50:15Z</updated> <link rel=\"self\" type=\"application/atom+xml\" href=\"https://api.zotero.org/users/1269166/items/47NPQRV2\"/> <link rel=\"alternate\" type=\"text/html\" href=\"http://zotero.org/eomc40/items/47NPQRV2\"/> <zapi:key>47NPQRV2</zapi:key> <zapi:itemType>book</zapi:itemType> <zapi:creatorSummary>Aron BeJesus</zapi:creatorSummary> <zapi:year/> <zapi:numChildren>0</zapi:numChildren> <zapi:numTags>0</zapi:numTags> <content zapi:type=\"html\" type=\"xhtml\"> <default:div xmlns=\"http://www.w3.org/1999/xhtml\"> <table> <tr class=\"itemType\"> <th style=\"text-align: right\">Type</th> <td>Book</td> </tr> <tr class=\"creator\"> <th style=\"text-align: right\">Contributor</th> <td>Aron BeJesus</td> </tr> <tr class=\"abstractNote\"> <th style=\"text-align: right\">Abstract</th> <td>A very nice book</td> </tr> </table> </default:div> </content> </entry></feed>"}
As per the point notes by Mronkko, I need assistance to perform item 1, since I don't understand what needs to be gathered from this data to get the "template" that is needed for the next steps.
I am new to programming and just need a guiding hand to understand how the bolts and nuts fit together.
When you post code, use a code posting service such as gist.github.com and format the code to be readable.
Bjoern
It is a pure Java wrapper of the Zotero API, albeit an incomplete one.