black friday sale

Flat 10% off on the purchase of any two apps or more. Use coupon code - FESTIVAL10

Grab It Now
Check Mobile App
Read now
Start a Project

Get Response as String from your Retrofit Call

Save

In This blog, we will learn about how to Get Response as String from your Retrofit Call.

Many times, during app development we need to use third-party modules and their response is not in our hand. I faced the same issue the response sent from third-party module was a simple string (no formatting done for any parser to work).

Being familiar with retrofit and its custom Converters for the response I got stuck with the response from this API. The response was in front of me through logs but was not accessible as retrofit was rejecting to detect it. So, I had to change the request a bit but implementing it was very easy.

APPROACH

  1. Your Call Should Expect the Default ResponseBody Object in response.
  2. When the response is received you need to call response.body().string() method to get the response as a plain string.

 

CODE

Retrofit call Object :

Retrofit Callback Object :

And That’s It.

Keep coding and Keep Sharing 🙂

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


2 comments

  • Richard
    Thank you very much for this! 🙂
    • anchit (Moderator)
      Your Welcome
  • css.php

    Very good company, we did get app extension for Magento 2 website. The support was very good they help us through the process. Webkul team is very supportive, I would recommend them.

    Yasser Mohamed

    Yasser Mohamed

    Talk to Sales

    Global

    Live Chat
    Start a Project

      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home