iOS sdk. FAULT = 'Server.Processing' [exception during method invocation]

Hello, I’m using the iOS SDK version 4.0.6 and when I do a retrieving some of the fields are empty.
I have the following class:

class Photo: NSObject {
var objectId: String?
var title: String?
var location: GeoPoint?
var imageUrl: String?
var username: String?
var datetime: Date?
var address: String?
var user: BackendlessUser?
var isVideo: String?
var videoThumbnail: String?
var voiceNoteUrl: String?
}

And both vars location and user are been nil when retrieving the data. Is like the “Autoload” option is disable, but I can asure you that is on.
I’m getting the error “FAULT = ‘Server.Processing’ [exception during method invocation]” when trying to save an object of the type Photo.
Using the version 3 of the sdk never got this problem.
Thanks for the help.

Could you please provide your Application Id?

Regards, Olga

Sure, is this: “752CC57D-33EE-ADE7-FFC6-06A0D032FE00”

We’ll investigate this issue and answer you as soon as possible.

Regards, Olga

Thanks Olga

Firstly, please update to the latest version of iOS-SDK (4.0.7).
I’ve checked this issue and everything looks fine.

Screenshot 1 - photos retrieving (only one photo from the retrieved photos), all relations are in place.
Here is the code:

 func getPhotos() {
 let photoStore = backendless.data.of(Photo.ofClass())!
 let photos = photoStore.find() as! [Photo]
 for photo in photos {
 print("***** PHOTO *****")
 print(photo.objectId!)
 print(photo.title!)
 print(photo.location!)
 print(photo.imageUrl!)
 print(photo.username!)
 print(photo.datetime!)
 print(photo.address!)
 print(photo.user!)
 print(photo.isVideo!)
 print(photo.videoThumbnail!)
 print(photo.voiceNoteUrl!)
 }
 }

Saving also works fine:

 func savePhoto() {
 let dataStore = backendless.data.of(Photo.ofClass())
 
 let newPhoto = Photo()
 newPhoto.title = "TEST PHOTO"
 newPhoto.imageUrl = "NEW PHOTO IMAGE URL"
 newPhoto.username = "NEW PHOTO USER NAME"
 newPhoto.datetime = Date()
 newPhoto.address = "NEW PHOTO ADDRESS"
 let savedPhoto = dataStore?.save(newPhoto) as! Photo
 
 let currentUser = backendless.userService.login("test@test.com", password: "111")!
 let userRelation = dataStore?.setRelation("user", parentObjectId: savedPhoto.objectId, childObjects: [currentUser.objectId])
 
 let geoPoint = GeoPoint.geoPoint(GEO_POINT(latitude:0.00, longitude: 0.00)) as! GeoPoint
 let savedGeopoint = backendless.geoService.save(geoPoint)!
 let geoRelation = dataStore?.setRelation("location", parentObjectId: savedPhoto.objectId, childObjects: [savedGeopoint.objectId])
 
 print("Photo saved")
 }

Screenshots 2, 3, 4 is what we’ve got after insert.
You can find a new record in you Photos table, a test user in the Users table and a new geoPoint with (0;0) coordinates.

Regards, Olga

Screenshot 1.png

Hello Olga, yes in fact with the find method is working fine.

Can you try with this variation of the find method please?

I’m still getting location and user equal to nil

Thanks a lot

let whereClause = "distance(\(coordinates.latitude), \(coordinates.longitude), location.latitude, location.longitude ) < km(\(distance))" 
 
 guard let dataQuery = DataQueryBuilder() else { return } 
 
 dataQuery.setWhereClause(whereClause) 
 
 dataQuery.setSortBy(["created desc"]) 
 
 
 
 



photoStore.find(dataQuery, response: { response in 
 
 guard let photos = response as? [Photo] else { return } 
 
 completion(photos, nil) 
 
 return 
 
 }, error: { error in 
 
 completion(nil, error) 
 
 return 
 
 }) 
 
 
 



Hello,
We are able to reproduce this issue. The internal ticket BKNDLSS-15715 created.
As a workaround you can add this line

dataQuery.setRelationsDepth(1)

We’ll try to solve this problem as soon as possible.

Regards, Olga

Thanks a lot for the help Olga

Do you have any idea why the saving object is not working either ??

Here is the complete function I’m using:

static func savePhotoWithUser(_ photo: Photo, completion: @escaping AppCompletion) {

        Backendless.sharedInstance().data.of(Photo.ofClass()).save(photo, response: { response in

            debugPrint(response as Any)

            completion(true, nil)

            return

        }, error: { (error) in

            debugPrint(error as Any)

            completion(false, error)

            return

        })

    }

Hi Nelson,

Please create a dedicated issue for the new problem and include a detailed description, e.g. the error text and a minimal example which could reproduce it.

Hello,

Please, check the new version of iOS-SDK (4.0.10) and verify wether the issue with nil location and user is solved.

Regards, Olga

Yes it is working fine without adding

dataQuery.setRelationsDepth(1)

Thanks