0

The API interface code in my Android client is:

import com.zift.myapplication88.models.ServerRequest;
import com.zift.myapplication88.models.ServerResponse;

import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.POST;

public interface RequestInterface {
    @POST("learn2crack-login-register/")
    Call<ServerResponse> operation(@Body ServerRequest request);
}

I get the following error when I try to send data to server though:

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $

I don't know where to edit in my code so I can make server return json not string.

Evin1_
  • 10,198
  • 8
  • 38
  • 47
fatima
  • 33
  • 3
  • Could you paste the JSON you receive from the server? – Evin1_ Aug 04 '17 at 20:39
  • This could also work for you: https://stackoverflow.com/questions/28418662/expected-begin-object-but-was-string-at-line-1-column-1 – Evin1_ Aug 04 '17 at 20:42

1 Answers1

0

You need to post the Server side code for getting suggestions on making changes to your server side. However, assuming that your server returns string (Which is a very bad practice), a workaround can be to write a custom converter for Retrofit.

Refer to Retrofit with String response

Dinesh Singh
  • 615
  • 7
  • 19