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 [2017/11/27 04:07] – Remove Zotero 5 warning bwiernikdev:web_api:v3:write_requests [2018/12/28 02:55] – [JSON Object Data] 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 -H "Expect:" $URL+$ curl -H "Zotero-API-Key: $API_KEY" -d @items.json -v $URL
 </code> </code>
  
-In this example, a JSON array of items is being saved to a text file, modified in a text editor, and then POSTed back to the same URL. (The ''-H %%"%%Expect:%%"%%'' is a requirement for cURL-based uploads, in order to disable sending of the unsupported ''Expect'' header.)+In this example, a JSON array of items is being saved to a text file, modified in a text editor, and then POSTed back to the same URL.
  
 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.
dev/web_api/v3/write_requests.txt · Last modified: 2021/06/02 16:30 by dstillman