Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
dev:web_api:v3:write_requests [2018/12/28 02:52] – [JSON Object Data] Removing the Expect header in cURL no longer seems to be required dstillmandev:web_api:v3:write_requests [2019/03/11 18:03] – [Multi-Object Requests] dstillman
Line 58: Line 58:
  
 <code> <code>
-$ URL="https://api.zotero.org/users/1234567/items?key=P9NiFoyLeZu2bZNvvuQPDWsd" +$ URL="https://api.zotero.org/users/1234567/items
-$ curl $URL > items.json+$ API_KEY="P9NiFoyLeZu2bZNvvuQPDWsd" 
 +$ curl -H "Zotero-API-Key: $API_KEY" $URL > items.json
 $ vi items.json  # edit the item data $ vi items.json  # edit the item data
-$ curl -d @items.json -v $URL+$ curl -H "Zotero-API-Key: $API_KEY" -d @items.json -v $URL
 </code> </code>
  
Line 67: Line 68:
  
 This approach allows a complicated task such as batch editing to be performed using only cURL and a text editor. Any objects modified in the text file will be updated on the server, while unmodified objects will be left unchanged. This approach allows a complicated task such as batch editing to be performed using only cURL and a text editor. Any objects modified in the text file will be updated on the server, while unmodified objects will be left unchanged.
 +
 +A similar process can be used with PUT for individual objects:
 +
 +<code>
 +$ URL="https://api.zotero.org/users/1234567/items/ABCD2345"
 +$ API_KEY="P9NiFoyLeZu2bZNvvuQPDWsd"
 +$ curl -H "Zotero-API-Key: $API_KEY" $URL > item.json
 +$ vi items.json  # edit the item data
 +$ curl -H "Zotero-API-Key: $API_KEY" -X PUT -d @item.json -v $URL
 +</code>
  
 Note that when uploading full JSON, only the ''data'' property is processed. All other properties (''library'', ''links'', ''meta'', etc.) are ignored. Note that when uploading full JSON, only the ''data'' property is processed. All other properties (''library'', ''links'', ''meta'', etc.) are ignored.
Line 390: Line 401:
   POST <userOrGroupPrefix>/collections   POST <userOrGroupPrefix>/collections
   Content-Type: application/json   Content-Type: application/json
-  Zotero-Write-Token: <write token> 
  
 <code>[ <code>[
Line 410: Line 420:
  
 <code>{ <code>{
-  "success": { +  "successful": { 
-    "0": "<objectKey>", +    "0": "<saved object>", 
-    "2": "<objectKey>"+    "2": "<saved object>"
   },   },
   "unchanged": {   "unchanged": {
Line 431: Line 441:
 }</code> }</code>
  
-The keys of the ''success'', ''unchanged'', and ''failed'' objects are the numeric indexes of the Zotero objects in the uploaded array. The ''Last-Modified-Version'' is the version that has been assigned to any Zotero objects in the ''success'' object --- that is, objects that were modified in this request.+The keys of the ''successful'', ''unchanged'', and ''failed'' objects are the numeric indexes of the Zotero objects in the uploaded array. The ''Last-Modified-Version'' is the version that has been assigned to any Zotero objects in the ''successful'' object --- that is, objects that were modified in this request.
  
 ^ Common responses ^^ ^ Common responses ^^
 | ''200 OK'' | The objects were uploaded. | | ''200 OK'' | The objects were uploaded. |
 | ''409 Conflict'' | The target library is locked. | | ''409 Conflict'' | The target library is locked. |
-| ''412 Precondition Failed'' | The provided Zotero-Write-Token has already been submitted. |+| ''412 Precondition Failed'' | The version provided in ''If-Unmodified-Since-Version'' is out of date, or the provided ''Zotero-Write-Token'' has already been submitted. |
  
  
dev/web_api/v3/write_requests.txt · Last modified: 2021/06/02 16:30 by dstillman