Hi this is urgent can you plz help

We are using following Api to save “Post” data on server
let dataStore = Backendless.sharedInstance().data.of(Post.ofClass())
dataStore!.save(post,
response: {
(post) -> () in
print(“Post saved”)
},
error: {
(fault : Fault?) -> () in
print(“Server reported an error: (fault)”)
})

I have tried to save data in both Sync and async manner . In both case we are not able to save data in table .
We get following error in our catch block “Printing description of fault:
FAULT = ‘Server.Processing’ [exception during method invocation] <exception during method invocation> ”

Our Application Id Is “4D6D3FC1-D343-A41B-FF81-A618C551BE00”

Can you guys plz help

What does the Post class look like?

Thnxs for the response. Here’s how post class looks like

Post class as below:
class Post: BackendlessEntity {
var owner : BackendlessUser?
var message : String = “”
var referencedPost : Post?
var repostedPost : Post?
var citedPost : Post?

var likeCount : Int = 0
var repostCount : Int = 0
var citedCount : Int = 0

var imageURL : String?
var image : Image? {
    didSet {
        if let image = image {
            imageURL = image.file?.fileURL
        } else {
            imageURL = ""
        }
    }
}

func isMine() -> Bool {
    guard let ownerUser = self.owner else {
        return false // if no owner, that's it's certainly not mine:)
    }
    return ownerUser.isUser()
}

func myLike() -> PostLike? {
    return NetworkService.sharedInstance.checkIfUserHasLikedPost(self)
}

func isLiked() -> Bool {
    if let like = self.myLike() {
        return like.isLiked
    }

Hello,

I’ve just checked the save method and no errors occurred.
Screenshot attached.

let newPost = Post()
        newPost.message = "TEST"
        newPost.likeCount = 111
        newPost.repostCount = 111
        newPost.citedCount = 111
        newPost.imageURL = "URL"
        
        let dataStore = Backendless.sharedInstance().data.of(Post.ofClass())
        dataStore!.save(newPost,
                        response: {
                            (post) -> () in
                            print("Post saved")
        },
                        error: {
                            (fault : Fault?) -> () in
                            print("Server reported an error: \(fault!.message)")
        })

If the error still occurs, please share the simple test project with this saving error so we could check this issue.

Regards, Olga

Hello Olga ,
Thanks , You are right . As I have checked same in above case .
But if we add owner and then request for the Api - same error occurs

I have attached a screen shot - as you can see we have added the owner in the post object , but when we hit Api we get same issue but if make it nil then api succeeds”

The internal ticket BKNDLSS-15422 was created.

The more information about setting the relation you can find here. Please, check it because the relation setting is different from the another properties setting.

E.g. this works fine for saving the Post object with 1:1 relation to the Users table:

let newPost = Post()
 newPost.message = "TEST"
newPost.likeCount = 111
newPost.repostCount = 111
newPost.citedCount = 111
newPost.imageURL = "URL"

 let dataStore = Backendless.sharedInstance().data.of(Post.ofClass())
 dataStore?.save(newPost,
 response: {
 (savedPost: Any?) -> () in
 dataStore?.setRelation("owner",
 parentObjectId: (savedPost as! Post).objectId,
 childObjects: [self.backendless.userService.currentUser.objectId],
 response: {
 (result : NSNumber?) -> () in
 print ("Relation has been saved")
 },
 error: {
 (fault : Fault?) -> () in
 print("ERROR: \(fault!.message)")
 })
 print("Post has been saved: \((savedPost as! Post).message)")
 },
 error: {
 (fault: Fault?) -> () in
 print("ERROR: \(fault!.message)")
 })

Regards, Olga

Hi Ogla, I have checked the above , and it saved the post . But still there are still few query. I tried it with Async method but didn’t received response ?. But worked with the sync method. I have also three columns which are referencePost ,repostedPost and citedPost with 1 to 1 relation , So I would again need to hit Api for the these three again to set relation? Can’t relation be set in dataStore!.save api in single hit? Is there any problem in relation setting on post Table ?

Yes, you need to hit Api every time you want to save the relation, they can’t be set only by the save method in Backendless 4.

Regards, Olga