Join Jon-Luke West for an in-depth discussion in this video Handle failed requests, part of Android Development: Retrofit with Java.
200 codes indicate that the request was successful.…300 codes indicate that the request is being redirected…and further action is needed by the client.…400 codes indicate that the client errored out…while making the request, either because of bad syntax…or because the request couldn't be started.…And 500 codes indicate that the request was made,…but the server failed to complete it.…
The response.isSuccessful method checks to see…if the response code is in the 200 or 300 category,…but you should always code your own logic…to determine what the response code was…and react accordingly.…Let's go back to Android Studio,…and write a method to handle one of the situations…we might encounter while using Github API.…In the project outline on the left,…right-click the Model package,…and create a new class.…
Call it NetworkUtil.…We will use this, so we only have to…write the method once for the whole app.…In this class, create a new public, static method…that returns a string called onGithubResponseError…that takes a response as a parameter…
- 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.