getting https://api.backendless.com/v1/binary error

Hi Hemangi,

I was able to get it working by changing the save call in the service class to the synchronous model. With the async version Realm complained about accessing realm objects from a different thread. That fix led to another discovery - Backendless didn’t like empty collection of postalAddressRelation. I made a change where empty collections for new entity objects are not sent to the server IF there is an uninitialized objectId property. So to get this working you need to do 3 things:

    Grab the latest jar from the github repo Change the save call in the service class to be synchronous (remove AsyncCallback) Add objectId getter/setter into the Profiles class.
Please let me know how it goes.

Regards,
Mark

Hi Mark ,

It is required to get or set object id using getter setter method or it is just for putting in model class not require to ser or get from code.

Hi Mark ,

Its done and now its work as i expected…
Thank you so much for a great help…

Excellent! Thank you for confirming.

Hi Mark,
When i update any record at that time instead of updating it will create new record in backendless.
Is there any need of setting objectId using getter setter method?

What you should do is this:

when you call Backendless.Data.of( YOURCLASS ).save( YOUROBJECT ), the method will return an updated object, which will contain assigned objectId. So the code should look like this:

Profiles updatedProfiles = Backendless.Data.of( Profiles.class ).save( realmProfilesObj );
realProfilesObj.setObjectId( updatedProfiles );

Regards,
Mark

Hi Mark ,

Actually what i want is when i save data from realm to Backendless it work fine but i want thai if i have 5 profile object from realm and from service i find object which are updated in realm so suppose i found 3 object from 5 is updated and try to save that in backendless it will not update already existing object but rather create a new object.

This is the code which i do in Service and this code will create new record rather than updating…
Realm profileRealm = Realm.getInstance(Helper.getProfileConfig(getApplicationContext()));
RealmResults<Profiles> resultsProfile = profileRealm.where(Profiles.class).findAll();
final List<Profiles> profilelist = new ArrayList<>();
for (Profiles profile : resultsProfile) {
try {
Date date1 = formatter.parse(Helper.getProfileLastUpdateTime(getApplicationContext())); // last sync date
String str2 = profile.getUpdatedDate();
Date date2 = formatter.parse(str2);
if (date1.compareTo(date2) < 0) {
profilelist.add(profile);
}
} catch (Exception e) {
}for (int i = 0; i < profilelist.size(); i++) {
Backendless.Data.of(Profiles.class).save(profile);
}}

Backendless will create new object if objectId is not set. If it is set to a valid id, then it will update that object.

Regards,
Mark

Ok i got it. Thanks