5 Apr 2012 (updated 11 Apr 2012 at 17:12 UTC)
»
How can I use curl to create stuff in TiddlyWeb?
Sometimes you may wish to create or update a
tiddler,
bag or
recipe from the command line and
twanager won't work for you for some reason. Maybe you are accessing a remote server. In these instances you can use
curl or
wget to make requests to the
TiddlyWeb server.
Below are some examples. In each of these the argument to the -d switch is a JSON string, so the use of
' and
" matter.
Please see JSON bag, JSON recipe and JSON tiddler for important details on the structure of the JSON that must be sent.Create or Update a Bag
curl -X PUT -H 'Content-Type: application/json' -d '{"policy":{}}' http://0.0.0.0:8080/bags/foobar
Create or Update a Recipe
curl -X PUT -H 'Content-Type: application/json' -d '{"recipe":[["system",""],["common",""]]}' \
http://0.0.0.0:8080/recipes/default
Create or Update a Tiddler
curl -X PUT -H 'Content-Type: application/json' -d '{"text":"hello"}' \
http://0.0.0.0:8080/bags/foobar/tiddlers/monkey
If you wish to
PUT a
binary tiddler you can do the following, assuming the source file is named
monkey.png:
curl -X PUT -H 'Content-Type: image/png' --data-binary @monkey.png \
http://0.0.0.0:8080/bags/foobar/tiddlers/monkey
See also:
HTTP APISyndicated 2012-04-05 17:49:07 (Updated 2012-04-11 16:16:06) from cdent