Java Reference
In-Depth Information
The body of the request contains all that you need to create the new user. The response includes the
URI to the representation of the user. This is a GET method request, like so: GET /users/123456 .
This requests details of the user with ID 123456.
If you want to update the user, you need to use the PUT method like so: PUT /users/123456 .
And if you want to delete the user, you use the DELETE method, like so: DELETE /users/123456 .
If you want to do a batch delete, it is acceptable to pass all the IDs of the users you want to delete in
the body of a call to DELETE /users . This would be far less chatty than multiple calls to each user's
resource.
You might want to get all users in the service like so: GET /users . This call would, of course, be
restricted by security so that only the users that the caller is authorized to view would be returned.
That is all for the user's context. Now you'll look at the follower's . A follower is a user who follows
another user because he is interested in that person's posts.
To get all the followers for a given user, use the GET method, like so:
GET /users/123456/followers
To create a new follower of a user, you pass the ID of that follower in the body of a request to
POST /users/123456/followers . You can get the details of the follower in one of two ways:
GET /users/123456/followers/456789
or
GET /users/456789
This is an example of how you can represent a resource in two different ways. To delete a follower
of a given user, you can do this:
DELETE /users/123456/followers/456789
This action removes user 456789 as a follower of user 123456 but does not actually delete the user.
However, the following deletes the user:
DELETE /users/456789
You have read about the followers context. Now you'll look at the topics and posts.
The topics noun and the
posts noun
You have already seen how to create a user by using the POST method. The same is true when
creating a topic and a post.
To create a topic, use:
POST /topics
To create a post under a topic, use:
POST /topics/123/posts
Note that you cannot create a post by doing this:
POST /posts
 
Search WWH ::




Custom Search