Retrofit - Send a simple POST Request | Android Studio Tutorial

Поділитися
Вставка
  • Опубліковано 13 сер 2020
  • 🏆 My Online Courses
    ⭐Discount Coupon: LAUNCH-STEVDZA-SAN
    stevdza-san.com
    🐱‍👤 Wanna become a member? Join!
    / @stevdzasan
    📸 Instagram
    / stevdza_san
    Retrofit is a Type Safe REST client for Android Developed by square. It uses okHttp library for HTTP requests, and it's one of the best tools for performing network requests in android applications. In this video I'll show you how to send POST request. For those of you who are not familiar with POST request. Basically POST is used to send data to a server to create/update a resource. The data sent to the server with POST request is stored in the request body of the HTTP request and not in the URL!
    Retrofit requires three main components:
    1. Retrofit Instance:
    We can create an instance of Retrofit by Retrofit.Builder class. And we have to specify the base url and converter factory at the time of the Retrofit instance creation
    2. Model Class:
    Retrofit needs a Model class for sending and receiving Request. It uses the model class for parsing server Response by using converters like Gson, Moshi etc.
    3. An Interface for possible API calls:
    The interface contains methods that represents possible API calls. Each methods need a base Url end point annotation that represents the Http methods like GET, POST etc.
    Project Files: github.com/stevdza-san/Retrof...

КОМЕНТАРІ • 58

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

    You're the best android teacher, tq so much

  • @Waleed_Al-Haidary
    @Waleed_Al-Haidary 3 роки тому

    Great touterial from talented expert. Thanks a million

  • @axw-ei3fn
    @axw-ei3fn 2 роки тому +1

    Very useful video . Simply explained . Thank you!

  • @MtaufiqH731
    @MtaufiqH731 3 роки тому

    What is differences of content type json with X Form url encoded?

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

    Great Explanation. Well done

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

    Very useful video . Thank you very much!

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

    Is the request body and key value pairs encrypted while sending it to the server ?

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

    thanks, that would be awesome if you could show how to post multipart (string and file)

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

    Hey there! You’re my new favorite kotlin developer! Subscribed. :) 🙌👏

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

    Thank You very much, Sir!)

  • @anmolsinghsahi5612
    @anmolsinghsahi5612 3 роки тому

    I got response body and response code, but no response message. Do you know why is that?

  • @Rafael-hk9pg
    @Rafael-hk9pg Рік тому

    What if I only get a status code back and not an object? I just want to know what status code I get back

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

    Hello! Hope you are doing it great! Thanks for your videos and Udemy courses, definitely a worthy purchase! I have a question since I have been trying it like 8 hours and can't figure out how to do it. In the else of 'if(response.isSuccessful)' you can handle all the errors of the app, but how can I handle no internet connection? I tried with try, catch, modifying the code, etc... But I can't do it. Have a nice day!

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

      hey i got similar problem,, have you found an answer to it yet?

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

    Thanks bro!!!

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

    Could you provide the Github link to this project?

  • @quewealawea
    @quewealawea 3 роки тому +1

    Awesome video!
    Is it necessary to use the "Response" class in the return of the method? you used "Response" but, couldn't it be only "post"?

    • @vikasbhadoriya1466
      @vikasbhadoriya1466 3 роки тому

      Hello my "Observer "{ response->}
      Didn't trigger what could be the problem??

    • @BrunoRibeiro-kz1np
      @BrunoRibeiro-kz1np 3 роки тому

      @@vikasbhadoriya1466 Hello! Try checking the viewModel.{responsetype} you have used? in my case i was wating a list response and in reality the response is a single record.

  • @user-gh1gl4go8u
    @user-gh1gl4go8u 3 роки тому +1

    hey, thank you for tutorials, can you tell the hotkey for getiing info about objects? you"re using this on 5:53

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

    Please we need a new tutorial using daggerhilt with retrofit. thank you for all you do

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

    @FormUrlEncoded is used to send simple data to the sever via Post method and it is not human readable form compared to Json, anyway great as intent!.

  • @prometheusli101
    @prometheusli101 3 роки тому

    you are good guy!

  • @h.r.60
    @h.r.60 3 роки тому +3

    "ahhh.. hello there"

  • @hafizushironawa9267
    @hafizushironawa9267 3 роки тому

    instead wireshark, can we use Postman to test the API?

    • @StevdzaSan
      @StevdzaSan  3 роки тому +1

      You can use anything you want

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

    when i click on for the one time it sends only one reponse but when i press button another time it sends response 4 times

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

      The observer must be outside the clicklistener

  • @vikasbhadoriya1466
    @vikasbhadoriya1466 3 роки тому

    Hello my "Observer "{ response->}
    Didn't trigger what could be the problem??

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

    Really enjoy your talking.

  • @funbaby1453
    @funbaby1453 3 роки тому

    How to create buying system. EX: online course application (Udemy). please make a video 😘

  • @joaquincamerlingo1244
    @joaquincamerlingo1244 3 роки тому

    hello , how would you insert and apikey ?

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

      For some API you can pass it with GET request in a form of URL and for some of them you need to include it in headers. Next video will be about headers.

  • @mrandroid6764
    @mrandroid6764 3 роки тому

    Do a tutorial on HILT.... Please bro

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

    please, sir, it possible to encrypt request and response prevent reading of sent data? ❤️

    • @StevdzaSan
      @StevdzaSan  3 роки тому +1

      Thank you for your suggestion I'll work on making new video about that.

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

      @@StevdzaSan Thank you sir for quick reply , wish you more creativity

    • @vikasbhadoriya1466
      @vikasbhadoriya1466 3 роки тому

      Hello my "Observer "{ response->}
      Didn't trigger what could be the problem??

    • @BrunoRibeiro-kz1np
      @BrunoRibeiro-kz1np 3 роки тому

      @@vikasbhadoriya1466 Hello! Try checking the viewModel.{responsetype} you have used? in my case i was wating a list response and in reality the response is a single record.

  • @mahmouddahdouh3811
    @mahmouddahdouh3811 3 роки тому +3

    Please , Make a video about how to send Image using Retrofit ❤️❤️❤️

  • @krishnamandava9919
    @krishnamandava9919 3 роки тому

    Please make retrofit file upload

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

  • @Irshadgbl
    @Irshadgbl 3 роки тому

    Great .....Please, sir, make videos on Firestore (save data and retrieve , update )

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

    hi sir help need pm me pls

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

    like

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

    was perfect in 0.75x haha

  • @B1LLSTAR
    @B1LLSTAR 3 роки тому +4

    This is not helpful. Please make a video with your code starting from scratch, because viewers don't want to drown in a sea of code right from the beginning.

  • @Irshadgbl
    @Irshadgbl 3 роки тому

    Great .....Please, sir, make videos on Firestore (save data and retrieve , update )

  • @Irshadgbl
    @Irshadgbl 3 роки тому

    Great .....Please, sir, make videos on Firestore (save data and retrieve , update )

  • @Irshadgbl
    @Irshadgbl 3 роки тому

    Great .....Please, sir, make videos on Firestore (save data and retrieve , update )