If you want to form encode data into the web call, Retrofit provides a convenient way to do this. By adding the @FormUrlEncoded annotation to a web call method, any parameter annotated with the @Field tag will be URL encoded, GET calls appended to the URL as a parameter, and POST calls included in the body of the request.
- [Instructor] Sometimes, an API will require you…to form URL encode the data you send to it,…instead of something like JSON or XML.…This means that the API will be looking for…all of the data in the URL as key value pairs,…just like query parameters.…Let's add a new method…to the GitHub service interface in the sample project,…so we can see what this looks like using Retrofit.…Please keep in mind…that this is merely an example based on…how I would configure the GitHub API…to accept form URL encoded data.…
You should always look…through the documentation for the API you are working with…to determine exactly how that API works.…Now, if the GitHub API accepted form URL encoded data…when we were trying to, lets say, create a comment…on a gist, this is how we would need to define the method.…Let's start by copying…and pasting the createCommentOnGist method,…and we're going to change some things.…
For starters, call this one…createCommentOnGistUrlEncode.…To indicate that this request is form URL encoded,…we need to add the…
- 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.