== Restolog Usage Will cover the usage of the Pure Ruby REST client ('script/rester'), part of the Restolog distribution. You can use also: $ curl -i -H 'Accept: application/xml' http://... for most of the examples. Some gotchas: $ curl -X POST ... (different method. Can be also PUT, DELETE, GET) $ curl ... http://admin:admin@localhost..../articles (authentication) $ curl ... -d 'comment[author]="Some User"&comment[body]="Very Good"' ... (past data) First change to the Restolog source directory and from there: * Articles, tags, users list (default method is GET), default URL: http://localhost:3000 $ script/rester /articles Code: 200 Message: OK Body:
1 2006-08-17T23:42:56+09:00 2 REST services 2
... $ script/rester /tags ... $ script/rester /users ... * Remote host and changed port $ script/rester -h remote.example.com -P 3002 /articles * Show particular article or user (GET): $ script/rester /articles/1 ... $ script/rester /users/2 ... * Create new article (POST, need authentication, using ';' for separator): $ script/rester -X POST \ -d 'article[title]=Test only;article[body]=Hello world;article[tag_list]=test rest' \ /articles Code: 401 Message: Unauthorized Body: Could't authenticate you $ script/rester -X POST -u admin -p admin ....{same as above} Code: 201 Message: Created Body: * Add comment (POST, no authentication required) $ script/rester -X POST \ -d 'comment[author]=Some User;comment[body]=Very Good' \ /article/1/comments Code: 201 Message: Created Body: * How the article with comment will looks like: $ script/rester /articles/1 Code: 200 Message: OK Body:
<p>Hello world</p> 1 2006-08-23T17:32:36+09:00 1 Test only 2 3 Some User Very Good 2006-08-23T17:34:51+09:00 1
* Change article title (PUT method, still not working :( ): $ script/rester -X PUT -u admin -p admin \ -d 'article[title]=Changed via XML' /article/1 ... * Delete comment or article (DELETE method): $ script/rester -X DELETE -u admin -p admin /articles/2/comments/1 Code: 204 Message: No Content Body: $ script/rester -X DELETE -u admin -p admin /articles/2 Code: 204 Message: No Content Body: