Is there any place where I can get samples of how to use the TW WebServer API?

95 views
Skip to first unread message

Rafael Oliveira

unread,
Jul 30, 2020, 6:38:52 AM7/30/20
to tiddl...@googlegroups.com
I'm trying to play with the TW Webserver API according to the documentation page but I haven't succeeded on creating a functional curl command. Is there any place where I can find practical samples of how to use it? Like curl samples just so I can work directly on the functional examples?

I've found other issues here in the forum about that like this one where people are facing the same problem... My assumption is that those requests may look simple for people who already master the REST API but they're not so simple for who's not familiar with it. I think I'd be really helpful if there was usable examples (like curl examples) in the official documentation (instead of just listing the kind of request and its parameters).

In my case I'd like to create tiddlers from a different application that's not TW... So the Web Server PUT Tiddler request would be useful for me... But I didn't manage to assemble the curl request successfully.

PMario

unread,
Jul 30, 2020, 7:52:52 AM7/30/20
to tiddl...@googlegroups.com
Hi Rafael,

This should do the trick. 

My commands where:

tiddlywiki test --init server
tiddlywiki test
--listen host=<yourIP>

In a different terminal:

curl -X PUT -i 'http://<yourIP>:8080/recipes/default/tiddlers/New' --data '{
 "tags": "FirstTag [[Second Tag]]",
 "my-custom-field": "Field value",
 "text": "your text comes here!
\n\nnext paragraph"
}'
-H "X-Requested-With: TiddlyWiki"

The info missing in the link was the X-Requested-With: Tiddlywiki header.

Be aware, that there is no username password if you start TW with the default --listen command.

I needed to use a linux terminal on a windows machine for the curl command. That's why I needed <yourIP>. If you work on a unix system you can use localhost instead.

have fun!
mario

PMario

unread,
Jul 30, 2020, 7:53:36 AM7/30/20
to TiddlyWiki
Hi,

The browser tab needs a reload to see the changes. ... Otherwise you'll have to wait up to a minute or so.

-m

Rafael Oliveira

unread,
Jul 30, 2020, 8:35:27 AM7/30/20
to TiddlyWiki
Thanks Mario, that worked for me :)

PMario

unread,
Aug 5, 2020, 3:55:13 AM8/5/20
to TiddlyWiki
For those who may find this thread:

If you want to create different tiddlers, you'll need to modify the URL and _not_ the title field in the --data block!

```

curl -X PUT -i 'http://<yourIP>:8080/recipes/default/tiddlers/New'
curl -X PUT -i 'http://<yourIP>:8080/recipes/default/tiddlers/New 1'
curl -X PUT -i 'http://<yourIP>:8080/recipes/default/tiddlers/New 2'
```
and so on.

have fun!
mario
Reply all
Reply to author
Forward
0 new messages