Skip to content
Advertisement

Getting error while using live currency conversion API by Retrofit in Android

// This is my MainActivity.java

JavaScript

}

// This is my RetrofitClient interface

JavaScript

}

// This is my ConvertAmt class (Model class where i am storing the result)

public class ConvertAmt { private double result;

JavaScript

}

// This is my StackTrace

JavaScript

2020-08-27 23:59:53.212 1471-1471/com.example.online_currency W/System.err: at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1401) 2020-08-27 23:59:53.212 1471-1471/com.example.online_currency W/System.err: at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:549) 2020-08-27 23:59:53.212 1471-1471/com.example.online_currency W/System.err: at com.google.gson.stream.JsonReader.peek(JsonReader.java:425) 2020-08-27 23:59:53.212 1471-1471/com.example.online_currency W/System.err: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:205) 2020-08-27 23:59:53.212 1471-1471/com.example.online_currency W/System.err: at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:39) 2020-08-27 23:59:53.212 1471-1471/com.example.online_currency W/System.err: at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:27) 2020-08-27 23:59:53.213 1471-1471/com.example.online_currency W/System.err: at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:223) 2020-08-27 23:59:53.213 1471-1471/com.example.online_currency W/System.err: at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:121) 2020-08-27 23:59:53.213 1471-1471/com.example.online_currency W/System.err: at okhttp3.RealCall$AsyncCall.execute(RealCall.java:206) 2020-08-27 23:59:53.213 1471-1471/com.example.online_currency W/System.err: at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) 2020-08-27 23:59:53.213 1471-1471/com.example.online_currency W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 2020-08-27 23:59:53.213 1471-1471/com.example.online_currency W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 2020-08-27 23:59:53.213 1471-1471/com.example.online_currency W/System.err: at java.lang.Thread.run(Thread.java:761)

Advertisement

Answer

It seems the data you are expecting from the response is not matching to the pojo that you are mapping this is what you are expecting,

JavaScript

actual response is

JavaScript

So you can convert your pojo to

JavaScript

and you can get the response like this

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement