Using a URI Template

If some of the properties of the object need to be in the URI being posted to you can use a URI template.

For example imagine you have a class Book that has a property called title. You can represent the title property in the URI template and then populate it from an instance of Book. For example:

Sending a JSON body with a URI template

  1. Flowable<HttpResponse<Book>> call = client.exchange(
  2. POST("/amazon/book/{title}", new Book("The Stand")),
  3. Book.class
  4. );

Sending a JSON body with a URI template

  1. Flowable<HttpResponse<Book>> call = client.exchange(
  2. POST("/amazon/book/{title}", new Book("The Stand")),
  3. Book.class
  4. );

Sending a JSON body with a URI template

  1. val call = client.exchange(
  2. POST("/amazon/book/{title}", Book("The Stand")),
  3. Book::class.java
  4. )

In the above case the title property of the passed object will be included in the URI being posted to.