Interface OAuthServerIntf.class:

@FormUrlEncoded @POST("authorize?response_type=token") Call<OAuthTokenYandex> requestTokenForm1( @Field("client_id") String client_id ); 

But the buider, what's wrong with it?

  @NonNull public static OAuthServerIntf yandexBuilder() { //Using Default HttpClient Retrofit retrofit = new Retrofit.Builder() .addConverterFactory(MoshiConverterFactory.create()) .baseUrl("https://oauth.yandex.ru/") .build(); OAuthServerIntf webServer = retrofit.create(OAuthServerIntf.class); return webServer; } 

Logs

 The call refreshTokenFormCall failed java.io.IOException: Use JsonReader.setLenient(true) to accept malformed JSON at path $ at com.squareup.moshi.BufferedSourceJsonReader.syntaxError(BufferedSourceJsonReader.java:1094) at com.squareup.moshi.BufferedSourceJsonReader.checkLenient(BufferedSourceJsonReader.java:990) at com.squareup.moshi.BufferedSourceJsonReader.doPeek(BufferedSourceJsonReader.java:374) at com.squareup.moshi.BufferedSourceJsonReader.peek(BufferedSourceJsonReader.java:202) at com.squareup.moshi.JsonAdapter$1.fromJson(JsonAdapter.java:65) at com.squareup.moshi.JsonAdapter.fromJson(JsonAdapter.java:33) at retrofit2.converter.moshi.MoshiResponseBodyConverter.convert(MoshiResponseBodyConverter.java:32) at retrofit2.converter.moshi.MoshiResponseBodyConverter.convert(MoshiResponseBodyConverter.java:23) at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:117) at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:211) at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:106) at okhttp3.RealCall$AsyncCall.execute(RealCall.java:135) at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818) 
  • Updated the question, look, please - Max Borisov
  • The error says Use JsonReader.setLenient(true) - i.e. something is wrong with the json conversion. I think we should look at what MoshiConverterFactory is - YuriySPb
  • I understand there is a problem in the converter. How to fix? - Borisov Max
  • Well, in theory, as in the error and said, add setLenient(true) in the builder thereof - YuriySPb
  • And if instead of moshi gsonfactory? - Borisov Max

0