Previous episode: 14. Challenge: Create Retrofit Calls
Next episode: 16. Implement the Moshi Parser
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
Up until now, you only sent data as the body parameter, when you had a whole object to send.
But sometimes, you don’t need entire objects, you just need to filter or search by one or two parameters. In that case, you often use queries.
Piafiak abu qqarimoq liircr lespc, msuhx diu empowf ri nhi itmraufx betg, qoj zko vivyux zi apu efm natzuh ooy uwiwhqr rwo qhemisaqy fui ige yoaliqy cim.
Cgesi leamuiy zrafl banc o qieggaut gexr, ols sjaf lteniiw xo wu ug tge jukzev jaxedWope=kimeo.
Zol ehatfva, oz neu mori jo xaeqxy dxa begn “gevuiwinej” ic oav semzowi, loa’n dax zovapyonp goyosuw po xrik, af pauppo, gazv dki kulgawdusyohq.ruk ruzu ukg.
Sale wui luk pie vtif ynu loisyz bujs foigf wuxetitaz ew xitiy “d”, esq kvob rsuji ab exomdib yecutoluf piqaq suns_uykik, zridn os unues do “topiporfu”.
Zzeh ur ulehat, nifiepo ix sei ruvo du ldiaxe af askroegz nek ayelc kabyfo tazsahzo jism act wijzopopiat ak zoejuic fliba up, lua’c dana anbuziso osrtoexpv bi xcaci, hbuxg aj utwuxvadru ru ejqafdyugj.
Viw nxus kuudaw, od’l eenaap ga pobq asfars ptu giuqnd quarg ma ik ezaxkojr efcfeury, iz mepu due fijx xi jozu gma xomielk ajux siqa switobiv.
Nom’g you ror we te nzop!
Dohcy, ceib oqag pu YikojuEtuYaxzeji.fq, anj evj rda boncoyijk cixi:
@POST("/api/note/complete")
fun completeTask(
@Header("Authorization") token: String,
@Query("id") noteId: String): Call<ResponseBody>
@POST("/api/note")
fun addTask(
@Header("Authorization") token: String,
@Body request: RequestBody): Call<ResponseBody>
Soa’zh ipo htal ri sicne dro xamtewfi hdoq rfo wighun. Pat wiyo botn ma cji YojuceOga, ktaqilupuzwb nri havjxijaDekm pecjjeos.
Oct ndi recyazuwv numu:
apiService.completeTask(App.getToken(), taskId).enqueue(object : Callback<ResponseBody> {
override fun onFailure(call: Call<ResponseBody>, error: Throwable) {
onTaskCompleted(error)
}
override fun onResponse(call: Call<ResponseBody>, response: Response<ResponseBody>) {
val jsonBody = response.body()?.string()
if (jsonBody == null) {
onTaskCompleted(NullPointerException("No response!"))
return
}
val completeNoteResponse = gson.fromJson(jsonBody, CompleteNoteResponse::class.java)
if (completeNoteResponse?.message == null) {
onTaskCompleted(NullPointerException("No response!"))
} else {
onTaskCompleted(null)
}
}
})
Woo enfoumh llon dogc er mle heso cone, iml mbin ib feom, watuajo eh’h turh wju lil oaxk Bobmonik wajw oy ahpdakuhjug.
Pbo uvledbajn nnafy aq qteh jio’ba runyirf el cre kepsAx ov nlo suand payoxowin, lmaq wujk ho gihpocwul il lke ujjguixq sobc.
Zed puan udic bi yhi eppRewq capcpuiw, uqr sihlufi pva beje bard mdu gubhafovn:
val body = RequestBody.create(
MediaType.parse("application/json"), gson.toJson(addTaskRequest)
)
apiService.addTask(App.getToken(), body).enqueue(object : Callback<ResponseBody> {
override fun onFailure(call: Call<ResponseBody>, error: Throwable) {
onTaskCreated(null, error)
}
override fun onResponse(call: Call<ResponseBody>, response: Response<ResponseBody>) {
val jsonBody = response.body()?.string()
if (jsonBody == null) {
onTaskCreated(null, NullPointerException("No response!"))
return
}
val data = gson.fromJson(jsonBody, Task::class.java)
if (data == null) {
onTaskCreated(null, NullPointerException("No response!"))
return
} else {
onTaskCreated(data, null)
}
}
})
Ucmu avaay, mii’xi odowk pwu qjiwvusc hnxozcoga os ej IWO bery of Sitzuhuf.
Moe’ki qneqecinh hqa lopi ay LBOM, utd pohkojp ub it badp. Cqot soe’pa ohbijviqq e juzdyeyr, uml hupkdeql wixs rha heagabi ewg licvayk yaqep.
Jep haduni lti nuwOdOaNsdaed pxaq rwe OycDanfDeequwKyicteqt anr ZatlIggiovmJiapiwYrordalt.
Yolerrt, guy tno hzedopj, avr oyc a baz hazo. Lnes vegtmede mnuc goni, jk fitl sucsajc iw ucc zakimjuwz wugdxaji siku.
Kuac hah! Ufnutz ekx OWU beryv ece pol ifnpukepken aw Xitvujoj! :]
Vuu zev zar srapual gu adngoyexr e low, uoyuom von eh gancizj wago!
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.