Support Topics Documentation Slack YouTube Blog

Unable to get response from backendless server to access my database table

hello,
hope you are doing good

I am new to android development and right now learning the basics of development via video tutorials and online classes.
Right now i am developing a app for storing contacts of a person and in it user can register and login and can create contacts under his user.

login and registration process is working fine via backendless but when i try to create new contact under any user i get the error code: Unable to adapt response to
but table in backendless backend has been created and its updated, but it is not showing in the app and thus app is not working as it should be.
every time i create a new user new entry in the backend table has been added, but i get fault response from the backend (which i created in your website).

app id: 16D70A95-F614-8BD8-FF14-95E330D06000

please look into this matter as soon as possible

regards

Hi @priyanshu_gupta!

Could you, please, provide sample of code which is used by you for user registration?

Regards, Andriy

else
{
    String name=etName.getText().toString().trim();
    String mail=etMail.getText().toString().trim();
    String phone=etPhone.getText().toString().trim();

    Contact_Table contactTable=new Contact_Table();
    contactTable.setName(name);
    contactTable.setNumber(phone);
    contactTable.setEmail(mail);
    contactTable.setUserEmail(ApplicationClass.user.getEmail());

    showProgress(true);
    tvLoad.setText("Update Contacts List..Please Wait");

    Backendless.Persistence.save(contactTable, new AsyncCallback<Contact_Table>() {
        @Override
        public void handleResponse(Contact_Table response) {

            Toast.makeText(Contacts.this, "New Contact Saved Successfully !!", Toast.LENGTH_SHORT).show();

            showProgress(false);

            etName.setText("");
            etMail.setText("");
            etPhone.setText("");

        }

        @Override
        public void handleFault(BackendlessFault fault) {

            Toast.makeText(Contacts.this, "Error: "+fault.getMessage(), Toast.LENGTH_SHORT).show();
            showProgress(false);

        }
    });

}


above is the code which i used for creating new contact user, contact_table is the name of database table, as you can see same table name in the backend also

It looks fine and should work without any errors. Could you also provide definition for Contact_Table class and code snippet for place where you initialize connection with Backendless?

Regards, Andriy

Contact_table ---------

public class Contact_Table
{
    private String name;
    private String number;
    private String email;
    private Date created;
    private Date updated;
    private String objectId;
    private String userEmail;

    public String getUserEmail() {
        return userEmail;
    }

    public void setUserEmail(String userEmail) {
        this.userEmail = userEmail;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public Date getUpdated() {
        return updated;
    }

    public void setUpdated(Date updated) {
        this.updated = updated;
    }

    public String getObjectId() {
        return objectId;
    }

    public void setObjectId(String objectId) {
        this.objectId = objectId;
    }
}




i write some declaration in ApplicationClass as i wanted it to available through out App
below is the declaration---
also i make correct declaration in the manifest file and gradle script--

public class ApplicationClass extends Application {
public static final String APPLICATION_ID = “16D70A95-F614-8BD8-FF14-95E330D06000”;
public static final String API_KEY = “09BF9242-547E-4214-8C73-8F2923587B24”;
public static final String SERVER_URL = “https://api.backendless.com”;

public static BackendlessUser user;
public static List <Contact_Table> contacts;

@Override
public void onCreate() {
    super.onCreate();
    Backendless.setUrl( SERVER_URL );
    Backendless.initApp( getApplicationContext(), APPLICATION_ID,API_KEY );

}

}

Could you change your code to print entire fault object by calling toString() on it and try try to run your code again? BackendlessFault object can contain additional information about your problem and can help me to figure out cause of it.

Regards, Andriy

Hello,
I have pasted error msg screenshot in attachment, please have a look at it.

regards

Could you please show also imports for Contact_Table class?

Regards, Andriy

Hello,
i am not sure what above request is?? but i have pasted an screenshot of contacts_table class, in which one import statement is written.

Hi @priyanshu_gupta!

Your problem caused by usage of wrong Date class. You must use java.util.Date instead of java.sql.Date. Change import for Date class and try again to create contact.

Regards, Andriy

Thank you, it works

regards