Backendless 4: addRelation returns "BackendlessFault{ code: 'Internal client exception'[...]}"

No joy for the new Backendless 4 relation API on my home computer :frowning:
Using the 2 examples below, I always receive the following error:BackendlessFault{ code: ‘Internal client exception’, message: ‘http://192.168.178.31:80/api/[...]/binary’ }

I am trying to add a relation of currently logged-in User with a “rsvp” column in Event table (one to many)
The data in the event and the backendlessUser objects is definitely ok, so there can’t be a problem there.
I have run an example multiple times and always without exception received an …exception (I could word that one better :slight_smile: )

Example 1
Event event = events.get(eventIndex); // personObject retrieval is out of scope in this example
BackendlessUser backendlessUser = Global.gCurrentUser; // addressObject retrieval is out of scope in this example

ArrayList<BackendlessUser> backendlessUsers = new ArrayList<>();
backendlessUsers.add( backendlessUser );

Backendless.Data.of(Event.class).addRelation(event, "rsvp", "email=\"jure@j.j\"",
        new AsyncCallback<Integer>() {
    @Override
    public void handleResponse(Integer response) {
        Log.i( "MYAPP", "related objects have been added");
        bRSVP = true;
    }

    @Override
    public void handleFault(BackendlessFault fault) {
        Log.e( "MYAPP", "server reported an error - " + fault.getMessage() );
        bRSVP = false;
    }
});

I have also tried to do it the other way.
Example 2:
Backendless.Data.of(Event.class).addRelation(event, “rsvp”, backendlessUsers,
new AsyncCallback<Void>() {
@Override
public void handleResponse(Void response) {
Log.i( “MYAPP”, “related objects have been added”);
}

@Override
public void handleFault(BackendlessFault fault) {
    Log.e( "MYAPP", "server reported an error - " + fault.getMessage() );
}

});

with the same BackendlessFault{ code: ‘Internal client exception’, message: ‘http://192.168.178.31:80/api/[...]/binary’ } risen.

The rest of the App is working nicely so I don’t have any idea what the problem might be.


Not related, but might be helpful to your company:
I noticed that the API has a different type(Void) then the documentation provided for Backendless 4 (Integer).
While they are both the same in the first example, the second example has mixed up types (Void for Integer).
The following is from documentation (compare with the above):
Backendless.Data.of( Person.class ).addRelation( personObject, “address”, addressCollection, new AsyncCallback<Integer>() { @Override public void handleResponse( Integer response ) { Log.i( “MYAPP”, “related objects have been added”); }

https://backendless.com/docs/android/doc.html#data_relations_api_set_add_android
I hope I have been of some help at least since I keep bothering you with these questions.
I must say I am enjoying the development with Backendless very much and you guys have provided me with most joy I have ever experienced in Java development! :smiley:
So thank you and I hope you keep it up!

Hi Jure,

Thanks for your kind words about Backendless :slight_smile:

Can we ask you to prepare a minimal code sample with with a data export so that we could import it to our app and reproduce the problem? Unfortunately, we haven’t been able to reproduce it in an ordinary example.

Thank you for the answer.
I wanted to create a minimal code sample before I asked the question, so I wouldn’t bother you in vain, but changed my mind since Backendless is now on my computer and didn’t know how it could benefit you this way.
I completely forgot about the data export! :smiley:

I will do it today.
Where would I send it?

Either attach it here or send to support@backendless.com. Thanks for your help!

I am sending the minimized version to support’s email now.

The only thing to do is add the KEY & APP_ID in the Constants Class, run the app and then click on any of the items in the list that shows up.

Hi Jure,

In the code you’re creating a relation which will be represented by column “rsvp”. The relation will be between an “Event” object and all objects matching the where clause "email=“jure@j.j”

The question is: what other table should “rsvp” point to? This is the table where the where clause will run. That information is not provided. Should it be “Users”, “Event” or “Body” ?

Regards,
Mark

It should point to Users table. But I don’t know what am I missing. Isn’t it enough that there exists a relationship in database between RSVP column in Event table and the Users table?
Where should I provide this information?
Can you help please?

This works though!!!

HashMap&lt;String, Object&gt; parentObject = new HashMap&lt;String, Object&gt;();
parentObject.put( "objectId", event.getObjectId() );


Backendless.Data.of( "Event" ).addRelation( parentObject,
"rsvp",
"email='jure@j.j'",
new AsyncCallback&lt;Integer&gt;()
{
@Override
public void handleResponse( Integer response )
{
Log.i( "MYAPP", "related objects have been added" );
}
@Override
public void handleFault( BackendlessFault fault )
{
Log.e( "MYAPP", "server reported an error - " + fault.getMessage() );
}
} );

but this doesn’t using the very same Event object

Backendless.Data.of(Event.class).addRelation(event, "rsvp", "email='jure@j.j'",
 new AsyncCallback&lt;Integer&gt;() {
 @Override
 public void handleResponse(Integer response) {
 Log.i( "MYAPP", "related objects have been added");
 }
 @Override
 public void handleFault(BackendlessFault fault) {
 Log.e( "MYAPP", "server reported an error - " + fault.getMessage() );
 }
});

Anyway… It looks that I can use Maps to solve this problem!
The Map version works perfectly!!!

Thank you for checking both approaches. We will investigate why the class-based approach is failing.

Just to confirm: you have the “rsvp” column defined in the Event table. The column points to Users and is declared as one-to-many, is that correct?

Regards,
Mark

Yes.
I have also sent the minimized version to support’s email yesterday if it helps. Complete with exported tables

http://support.backendless.com/public/attachments/b1578ac22ee17b16160aaf5a62367dc0.png&lt;/img&gt;

I think this has the wrong flag “Waiting for user’s response”