Defining a call with Retrofit to make a POST request is just as easy as defining one for a GET request. The @POST annotation is used on the method definition instead of @GET, and when you are using a converter to serialize the data, you can pass the whole object to the method and it will be serialized and sent to the server leaving out any properties that are null.
- [Instructor] The last thing to do…to finish this application,…is allow the user to post new comments to a gist…in the GitHub service interface.…To make this easier,…copy the getGistCommentHeadersByID method,…and below our unstarGistByID method, paste it.…Call this createCommentOnGist.…
Now to create a new gist comment,…we will need to make a post request,…to slash Gists slash the gistID slash comments.…This request should return a Gist comment…instead of a void,…which will be the state of the new comment…once it is created.…Where we will post a comment with nothing but a body,…the comment returned to us will include an ID,…a created time, and all of the other properties…of a gist comment.…
And because post requests are expected to have a body,…we need to always make sure…that we include a parameter in the method definition.…A gist comment in this case, called comment.…This parameter will need to be annotated…with an @body annotation to indicate to Retrofit…that it should take this data,…serialize it according to the converter factory…
- REST API basics
- Methods for reading and writing data
- Defining data models with Retrofit
- Implementing an API interface
- Getting data with a Retrofit call
- Authorizing requests
- Putting, deleting, and posting data
- Customizing the data converter
- Working with the request and response headers
Skill Level Intermediate
Android App Development: Enterprise Integrationwith Jon-Luke West47m 51s Intermediate
Android App Development: Data Persistence Librarieswith Annyce Davis4h 52m Intermediate
1. HTTP APIs
2. Get Started with Retrofit
3. Finish the Sample App
4. More Configuration Options
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.