I wanted to use retrofit library for parsing and posting the data by passing some parameters. But When defining model class some times we will use @Serialized in-front of variable, What is the use of that Serialized.And What is the difference between @Get and @Query in passing params to API.Can Any one explain the difference.
Lets say you have api method @GET("/api/item/{id}/subitem/")
so by using @Path("id")
you can specify id for item in path. However your api may take additional parameters in query like sort, lastupdatetime, limit etc so you add those at end of url by @Query(value = "sort") String sortQuery
So full method will look like:
@GET("/api/item/{id}/subitem")
SubItem getSubItem(@Path("id") int itemId, @Query("sort") String sortQuery, @Query("limit") int itemsLimit);
and calling api.getSubItem(5, "name", 10)
will produce url @GET("/api/item/5/subitem/?sort=name&limit=10")
and @Get
is HTTP method
http://www.w3schools.com/tags/ref_httpmethods.asp says
Two commonly used methods for a request-response between a client and server are: GET and POST.
GET - Requests data from a specified resource POST - Submits data to be processed to a specified resource
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With