How to Make HTTP Requests With Ktor-Client (Cooler Than Retrofit!) - Android Studio Tutorial

Поділитися
Вставка
  • Опубліковано 1 жов 2021
  • Network requests with Ktor? Yes, that's possible! In this video you'll learn how.
    ⭐ Get certificates for your future job
    ⭐ Save countless hours of time
    ⭐ 100% money back guarantee for 30 days
    ⭐ Become a professional Android developer now:
    pl-coding.com/premium-courses...
    💻 Let me personally review your code and provide individual feedback, so it won't backfire and cost you a fortune in future:
    elopage.com/s/philipplackner/...
    Subscribe to my newsletter for regular Android, Kotlin & Architecture advice!
    pl-coding.com/newsletter
    Join this channel to get access to perks:
    / @philipplackner
    Get the source code for this video here:
    github.com/philipplackner/Kto...
    Regular live codings on Twitch:
    / philipplackner
    Join my Discord server:
    / discord
    Regular programming advice on my Instagram page: / _philipplackner_
    Checkout my GitHub: github.com/philipplackner
    You like my free content? Here you can buy me a coffee:
    www.buymeacoffee.com/philippl...

КОМЕНТАРІ • 106

  • @niranz7745
    @niranz7745 2 роки тому +1

    Yes! I love Ktor videos. Can't wait for the KMM videos as well. Thank you Philipp

  • @kinggeorges625
    @kinggeorges625 2 роки тому +3

    Thanks for the video and efforts you are putting to help people you don't even know. Stay blessed

  • @vengateshm2122
    @vengateshm2122 2 роки тому +5

    Hey Phillip last week I learnt ktor client for android and I thought you will put a video on that.
    Coo I predicted it.
    You are better teacher.

  • @mattgraves3709
    @mattgraves3709 2 роки тому

    I appreciate that we implement the interface with KTOR.

  • @bertafitocasas7791
    @bertafitocasas7791 Рік тому +1

    Hi! Thank you very much. You seem to have saved our project :)

  • @azamovdev
    @azamovdev Рік тому +3

    I have been using Retrofit2 for a long time, after this video I realized that ktor is very light and easy, thank you very much

    • @truongxuan8322d
      @truongxuan8322d Рік тому +2

      can you give me the names of youtube channels to learn how to build resfull api + kotlin retrofit?

  • @jatinvashisht4293
    @jatinvashisht4293 2 роки тому +7

    Thumbnail is lit 🔥

  • @sergeytarasov5041
    @sergeytarasov5041 2 роки тому +7

    Phillip, you explain it so easy and good, I am very impressed, thank you.

  • @slayer5171
    @slayer5171 2 роки тому

    This is impressive, thanks for sharing.

  • @siva_subramaniam
    @siva_subramaniam Рік тому

    Great content. Thanks Philipp.

  • @madalitsophiri3728
    @madalitsophiri3728 2 роки тому

    finally a good tutorial on ktor

  • @nonconsensualopinion
    @nonconsensualopinion 2 роки тому

    Another great video. Thanks!

  • @Another0neTime
    @Another0neTime 2 роки тому

    Great work! Bravo.

  • @user-uu8rn6wf4u
    @user-uu8rn6wf4u Рік тому

    Thank you Philipp!

  • @mattgraves3709
    @mattgraves3709 2 роки тому

    Great Video!
    Thanks Phillipp

  • @alij3fer
    @alij3fer 2 роки тому

    🔥😍 Thanks bro

  • @richardwilkinson7873
    @richardwilkinson7873 2 роки тому

    Once again awesome video :) Is there another video to explain how to consolidate input fields into json and POST??

  • @shanahjrsuping7344
    @shanahjrsuping7344 2 роки тому +1

    Hi Phillip, thank you so much for the video. It has opened my eyes quite a a bit as I would like to get into native app development. My question is, would it be possible to use generics for the post service so that the code doesn't need to be copied and pasted so many times?

  • @nabazbarzanji3221
    @nabazbarzanji3221 2 роки тому

    That's awesome💯

  • @SuessesSumpfhuhn
    @SuessesSumpfhuhn 2 місяці тому

    Hey Philipp, thanks for this amazing video! I'd need to know how to send more complex client requests with parameters and basic authentication details to the server. Could you maybe do a second video on this?

  • @coldwolf5050
    @coldwolf5050 2 роки тому

    Good video, did not know ktor can be used in Android as well.

  • @rivaldohadiwinata6803
    @rivaldohadiwinata6803 Рік тому

    very helpful !

  • @quantumgaming7
    @quantumgaming7 2 роки тому +2

    Retrofit still wins 💕💕

  • @Coldalecs
    @Coldalecs 9 місяців тому +4

    Very good info! But this is already outdated, for example instead of `install(JsonFeature)` you now have `install(ContentNegotiation){json()}`. Good work, Philipp!

    • @allanaraujo2157
      @allanaraujo2157 5 місяців тому

      thank you

    • @allanaraujo2157
      @allanaraujo2157 5 місяців тому +1

      install(ContentNegotiation) {
      json(Json {
      isLenient = true;
      ignoreUnknownKeys = true
      })
      }

  • @Ceisluck
    @Ceisluck 2 роки тому +1

    Did you mesaure the eficency of this change in terms of speed/size etc or this is another random video in youtube?

  • @raheemadamboev
    @raheemadamboev 2 роки тому +2

    Hey Philipp! Could you make a tutorial about creating your own android library and publishing with the help of jitpack in gradle 7.0 please

  • @CarlosSilva-mm8py
    @CarlosSilva-mm8py 2 роки тому +28

    Hi Phillip, could you record a video about MVVM + Clean Architecture + FirebaseAuth / FirebaseRealTimeDataBase, I have many doubts about this and I believe it will help not only me but others as well. Great video.😆😆😆

    • @user-kd4gl9rf5k
      @user-kd4gl9rf5k 2 роки тому +8

      Real-time database is not used anymore. Firestore is the better option

    • @nicolasdev7220
      @nicolasdev7220 2 роки тому +2

      @@user-kd4gl9rf5k why? which is the most used now?

  • @ekhiw
    @ekhiw 2 роки тому +1

    How to make stream data for download large file using ktor?
    Or make a multipart post request for upload large file?

  • @sebastianpalm3495
    @sebastianpalm3495 10 місяців тому

    Great video as always I have one question how do you configure the client to accept self signed certificates?

  • @marlonlom
    @marlonlom Рік тому

    Hi Phillip, thank you so much for the video. wanna ask about unit testing ktor client and spi implementation using mocks, the json examples and its usang in unit and integratin tests :)

  • @ashutoshandhare7626
    @ashutoshandhare7626 2 роки тому

    Hey, how do we use the create post function? Like I've been searching for a whole day now on how to send a post request, but none have shown the way to call the post function from the main_activity.kt file. We created the functions and implementations for post request, but how do we really call that from the main function?

  • @khanzadakashif8248
    @khanzadakashif8248 2 роки тому +2

    I can't decide what's more creative,
    Your videos or your thumbnails...😆

  • @re_allyedge
    @re_allyedge 2 роки тому +28

    Hey Philipp! Could you make a tutorial about Authentication using both Ktor server and Ktor client?

    • @vengateshm2122
      @vengateshm2122 2 роки тому +2

      Yes there are several authentication. We can start with basic and jwt.

    • @vyas8137
      @vyas8137 2 роки тому +2

      @@vengateshm2122 bro could you suggest me some good android development resources?

    • @vengateshm2122
      @vengateshm2122 2 роки тому +3

      @@vyas8137 Phillip lackner
      Simplified coding
      Coding in flow
      Rahul Pandey
      Slidenerd
      Android developers documentation, especially code labs.

    • @vyas8137
      @vyas8137 2 роки тому +1

      @@vengateshm2122 bro could you please provide the links for beginners I just know basic kotlin so what all I should look for as the android development domain is always changing.

    • @vengateshm2122
      @vengateshm2122 2 роки тому +2

      @@vyas8137 Start with recycler view, activity, fragment, camera, services, content provider. MVP concepts then mvvm

  • @storypur
    @storypur 2 роки тому

    Is ktor good for making large-scale android applications?

  • @fnax
    @fnax 2 роки тому

    Very good video and library! Can it be used for xml apis ?

  • @japneetraina8146
    @japneetraina8146 Рік тому

    ha shilli waa philipp lakdi walli

  • @emmanuelmtera5936
    @emmanuelmtera5936 2 роки тому

    Hello Philip followed the video in all steps but suddenly i always get 400 error , what step might have i gone wrong? is it the data class maybe or ? versions? Thanks in advance.

  • @devOmarAZ
    @devOmarAZ 2 роки тому +2

    really what is the difference between java serializable and kotlin serializable ?
    and kotlin serializable vs parcelable?
    java serializable vs kotlin serializable vs parcelable ?

  • @user-kq8yo1qu7m
    @user-kq8yo1qu7m 2 роки тому

    Great!!!

  • @aabhishek4911
    @aabhishek4911 2 роки тому +1

    Btw retrofit can be used for any java/kotlin project , not just android

  • @PritamDas-rj5fk
    @PritamDas-rj5fk 2 роки тому +1

    after update the ktor to 2.0 its show error in clint.get
    mismatch
    help??

  • @SaherAlSous-welcomes-you
    @SaherAlSous-welcomes-you 2 роки тому

    thank you

  • @myrzabekylychev5112
    @myrzabekylychev5112 2 роки тому

    Nice! Thank you! Can you provide video with uploading image to server using multipart form data, please?

    • @vengateshm2122
      @vengateshm2122 2 роки тому +1

      Hey I would suggest follow ktor doc.
      I know Phillip videos are awesome but if you don't try to understand on your own you will end up searching for tutorials all time.
      Phillip is investing his valuable time to provide quality content.
      Hope he will cover the topic also that you want.
      Meanwhile You can look into the docs and give a try.
      If you did then go ahead and write an article in medium or dev.to what you learnt.
      You will feel confident b that time.

  • @TheZukkino
    @TheZukkino Рік тому +3

    You might do an update for v 2.x.x cause of many plugin changes.

  • @MtaufiqH731
    @MtaufiqH731 2 роки тому +1

    So we use ProduceState is a trick to make an app without viewmodel.? So the data still dynamic and the state is not change if we rotate the phone.?

    • @PhilippLackner
      @PhilippLackner  2 роки тому +1

      No don't get this wrong. I just don't used a viewmodel here because the focus is on ktor. Just to get an understanding of how the ktor library works

  • @RoniTadmor
    @RoniTadmor Рік тому +1

    Great video :) any chance for an update for varsion 2... ?

  • @veygard
    @veygard 2 роки тому

    ty for video

  • @youprimeprime3046
    @youprimeprime3046 2 роки тому +2

    can you make more videos related to ktor stuff thanks

  • @priyaranjanmantri9332
    @priyaranjanmantri9332 2 роки тому

    Hey it's awesome...

  • @sebastianpalm3495
    @sebastianpalm3495 10 місяців тому +1

    Is a really good video sadly a bit outdated because of the changes in Ktor any plans to do another one in the future?

  • @PritamDas-rj5fk
    @PritamDas-rj5fk 2 роки тому

    can i create a data class with only my nessary variable
    like can i create data class without body and user id

  • @fensom80
    @fensom80 Рік тому

    Okay, so to put it all together, Kotlin Multiplatform using clean architecture and MVI using Ktor? to call a NodeJS Graphql server
    UI will be Jetpack Compose for Android and SwiftUI for Apple products. Can you please make this video or better option. Please? Thankyou!!!!!

  • @muhammadhassaansiddiqi8586
    @muhammadhassaansiddiqi8586 2 роки тому +1

    please make video for c.Arci + KTOR with Full Error handling. both get and post apis. please
    di how we use in ktor

  • @Muhfara
    @Muhfara 2 роки тому

    please make a coin tutorial and your feedback about coins compared to dagger hilt

  • @vedx
    @vedx 2 роки тому +1

    Cool 😘

  • @gorkemozgur6796
    @gorkemozgur6796 2 роки тому

    I wonder how you can do interceptor like okhttp client

  • @sanjaybhatikar
    @sanjaybhatikar 11 місяців тому

    Cool! How to make an OAuth call and stash a JWT token to send with requests? Cheers!

  • @Somerandomnessvvv
    @Somerandomnessvvv 2 роки тому +2

    Is this also applicable when using ktor websockets?

  • @RoKotEyn
    @RoKotEyn Рік тому

    But how do I refresh it with click of a button, though?

  • @ymusclecode
    @ymusclecode 2 роки тому

    I have 2 emulators, on android 11 does not work, on android 8 works as expected

  • @abhijith_mogaveera
    @abhijith_mogaveera 2 роки тому

    That means, can we can also use this for interactions with Socket..?

  • @vyas8137
    @vyas8137 2 роки тому

    Hey man! Could you suggest some good resources to learn Android development from beginners to advanced , Cause I tried numerous resources most of them are outdated and some don't work properly.

    • @cleancodez
      @cleancodez 2 роки тому +1

      i think is here, i learnt from him since my start, and now i can make apps through his knowledge, Philip this is great.
      i also have some conted though my audio is not good, you can check if they might be of help to you.
      Just click my profile. but remember, Philip has almost what you need to get started as a pro dev

    • @vyas8137
      @vyas8137 2 роки тому

      @@cleancodez will check, thanks mate : )

  • @BearkFearGamer
    @BearkFearGamer 2 роки тому

    Better than retrofit!

  • @irfanirawansukirman4809
    @irfanirawansukirman4809 2 роки тому

    Hi Phillip, how to use Chuck/Chucker using Ktor? thanks

  • @mehranj73
    @mehranj73 2 роки тому +1

    I think Ktor-Client is also suitable for compose desktop.

    • @PhilippLackner
      @PhilippLackner  2 роки тому +2

      Sure since it's a kotlin library

    • @maskedredstonerproz
      @maskedredstonerproz 2 роки тому +1

      Speaking of compose desktop, Philipp are you ever gonna take a look at that and show us a few things about it???

    • @mehranj73
      @mehranj73 2 роки тому

      @@maskedredstonerproz too soon

    • @maskedredstonerproz
      @maskedredstonerproz 2 роки тому

      @@mehranj73 what do you mean too soon??

    • @mehranj73
      @mehranj73 2 роки тому

      @@maskedredstonerproz It is not production ready and you can also try it in IntelliJ. Compose desktop in still jetpack compose.

  • @alleaffen1926
    @alleaffen1926 Рік тому

    Hello, I need to use a get-request to get the bearer token and then use this token for another get-request where for the profile-informations. Is this possible with Ktor? I am relatively new on this programming things, so maybe someone could give me some hint/s.. Thanks in advance. And thanks for this clear tutorial, it helped me a lot :)

    • @vinayparmar7361
      @vinayparmar7361 Рік тому

      hey, I am at the situation where you were month ago.. I am having the concern.. can you please recommend the way if you have found the solution?

    • @alleaffen1926
      @alleaffen1926 Рік тому

      @@vinayparmar7361 sorry, no not yet.. Hadn't much time to try it. Did you success in the meantime?

    • @alleaffen1926
      @alleaffen1926 Рік тому

      @@vinayparmar7361 I think the solution is saving the received token with shared preferences and then add the token with the @Header annotation..

    • @TheZaurHasanov
      @TheZaurHasanov 19 днів тому

      ​ @vinayparmar7361 did you guys find the way?

  • @subyk6046
    @subyk6046 9 місяців тому

    13:35 isnt better wrap result in repository? In repository I call api.getPost function who will return Result and in VW i can handle onSuccess and onFailure.
    Btw thanks a lot for the video. :)

  • @thkorkem
    @thkorkem 2 роки тому

    Nice video. However, Retrofit is much simpler and useful than that.

  • @pritamdas1156
    @pritamdas1156 Рік тому

    how to make request with Credentials

  • @suneelkumar-hm4kd
    @suneelkumar-hm4kd 2 роки тому

    10:31

  • @mohamadrezazandieh3003
    @mohamadrezazandieh3003 8 місяців тому

    awli bood haji

  • @mrwhoknows
    @mrwhoknows 2 роки тому

    0th

  • @TreudtLP
    @TreudtLP Рік тому

    Mega scheiße das Video, absoluter Müll die Hälfte des Screens nicht einzublenden

  • @ChristiaanHunter
    @ChristiaanHunter 3 місяці тому

    hi Mr Lackner, i am still learning but a bit confused with the build.grade.kts, my file looks like this dependencies { implementation(libs.androidx.core.ktx)... your gitHud looks like this dependencies { implementation 'androidx.core:core-ktx:1.6.0'....
    I guessing this is a different language format to set the dependencies ?
    thanks for your vids

  • @Joe-pz4ss
    @Joe-pz4ss Рік тому +1

    I am getting an Unresolved reference: JsonFeature error. I found one stackoverflow post but it didn't fix my issue. I have the following dependencies:
    def ktor_version = "2.2.2"
    implementation "io.ktor:ktor-client-core:$ktor_version"
    implementation "io.ktor:ktor-client-android:$ktor_version"
    implementation("io.ktor:ktor-client-apache:$ktor_version")
    implementation("io.ktor:ktor-client-json:$ktor_version")
    implementation "io.ktor:ktor-client-serialization:$ktor_version"
    implementation "io.ktor:ktor-client-logging:$ktor_version"
    implementation "ch.qos.logback:logback-classic:1.4.5"
    implementation("io.ktor:ktor-client-content-negotiation:$ktor_version")
    implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0"

    • @flychee123
      @flychee123 Рік тому +1

      works for me with the same dependencies but 2.2.3 and the following code instead of the JsonFeature: install(ContentNegotiation){
      json(Json{
      prettyPrint = true
      isLenient = true
      })
      }