-1

I am trying to register a user with an API and after successful registration i am expecting a user id like [234] in response. But i am getting the mentioned error.Registration part include 13 fields including edit text,checkbox,and a spinner.the problem is occurred when i am trying to get the timezone value from API and populate it with a value.

i just stuck at this conversion and don't know where i am doing wrong.enter code here `

  • post the json response from the API – Manoj Perumarath Nov 05 '18 at 05:25
  • post your json here? – sushildlh Nov 05 '18 at 05:26
  • 2
    Possible duplicate of ["Expected BEGIN\_OBJECT but was STRING at line 1 column 1"](https://stackoverflow.com/questions/28418662/expected-begin-object-but-was-string-at-line-1-column-1) – Jaymin Nov 05 '18 at 05:34
  • 1
    Which line you are getting the error. Kindly post the log and json structure – abhil nair Nov 05 '18 at 05:42
  • this is the response i am getting when i am posting it in postman with parameters.but problem is that when i am pressing the signup button it should send this response in the emulator too instead i am getting the error which i asked .@ManojPerumarath[ 793 ] – Vipan Verma Nov 05 '18 at 05:50
  • @Jaymin it shouldn't be .i am just a newbie to retrofit.i think i have done wrong with my code .please help me out. – Vipan Verma Nov 05 '18 at 05:56
  • first, check your API on the postman. I think your response is not the right format. – Shiva Kanumala Nov 05 '18 at 06:01
  • @ShivaKanumala No,the response is ok.thats what i want to get. but when i am registering through emulator in studio it is not showing me the id . – Vipan Verma Nov 05 '18 at 06:06
  • okay. then check in your mobile device. because it's easy to find whether the problem is coming only emulator or all. – Shiva Kanumala Nov 05 '18 at 06:11
  • @ShivaKanumala same error. – Vipan Verma Nov 05 '18 at 06:34
  • for onResponse you write this line 'if(response.code()==200){ Log.d("message", "" + response.message()); }' – Shiva Kanumala Nov 05 '18 at 06:48
  • Few things you need to understand before posting question on StackOverflow. 1) You posted only code that you've tried. 2) There's no API sample (explanation) like expected params, response format etc in your question. (Not all people are aware of all the APIs) 3) If you get errors care to log it properly and post it along with your question. 4) Comments are meant to ask clarification, suggest improvements and not for extended discussion. If you take care these things, it'll be helpful us to help you ASAP. Moreover it save a lot of time. Good luck – Shashanth Nov 05 '18 at 07:02
  • API =https://www.moremovies.com/service/register_user.php? parameters - fname, lname, email_id, password, mobile, madd, madd_from, newsletter, address, office_no, company, website, timezone all above parameters are compulsory- in newsletter you have to show checkbox and pass parameter 0 or 1 , here 0 means yes and 1 means no - "madd" you will have to get MAC address of Android device in backend and send to server at the time of signup and in "madd_from" you will be sending "Android", each Android device should have unique MAC address @Shashanth – Vipan Verma Nov 05 '18 at 07:20

1 Answers1

0

I think your json will be different. you need to fetch json response from server based on objectType but getting string.

You used robopojo plugins for pojo class generate.

then pass response class into post api.

For example ..

public class ResponseData {

@SerializedName("code")
private Integer code;
@SerializedName("error_message")
private Object errorMessage;
@SerializedName("data")
private List<Datum> data = null;

public Integer getCode() {
    return code;
}

public void setCode(Integer code) {
    this.code = code;
}

public Object getErrorMessage() {
    return errorMessage;
}

public void setErrorMessage(Object errorMessage) {
    this.errorMessage = errorMessage;
}

public List<Datum> getData() {
    return data;
}

public void setData(List<Datum> data) {
    this.data = data;
}

}
Android Team
  • 11,274
  • 2
  • 26
  • 46