Backendless Support
 
Waiting for user's response

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

Leave a Comment

Comments (7)

photo
1

What does the Post class look like?

photo
1

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

}

photo
1

Hello,

I've just checked the save method and no errors occurred.

Screenshot attached.

  1. let newPost = Post()
  2. newPost.message = "TEST"
  3. newPost.likeCount = 111
  4. newPost.repostCount = 111
  5. newPost.citedCount = 111
  6. newPost.imageURL = "URL"
  7. let dataStore = Backendless.sharedInstance().data.of(Post.ofClass())
  8. dataStore!.save(newPost,
  9. response: {
  10. (post) -> () in
  11. print("Post saved")
  12. },
  13. error: {
  14. (fault : Fault?) -> () in
  15. print("Server reported an error: \(fault!.message)")
  16. })

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

Regards, Olga

photo
1

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”

Files: SS.png
photo
1

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:

  1. let newPost = Post()
  2. newPost.message = "TEST"
  3. newPost.likeCount = 111
  4. newPost.repostCount = 111
  5. newPost.citedCount = 111
  6. newPost.imageURL = "URL"
  7. let dataStore = Backendless.sharedInstance().data.of(Post.ofClass())
  8. dataStore?.save(newPost,
  9. response: {
  10. (savedPost: Any?) -> () in
  11. dataStore?.setRelation("owner",
  12. parentObjectId: (savedPost as! Post).objectId,
  13. childObjects: [self.backendless.userService.currentUser.objectId],
  14. response: {
  15. (result : NSNumber?) -> () in
  16. print ("Relation has been saved")
  17. },
  18. error: {
  19. (fault : Fault?) -> () in
  20. print("ERROR: \(fault!.message)")
  21. })
  22. print("Post has been saved: \((savedPost as! Post).message)")
  23. },
  24. error: {
  25. (fault: Fault?) -> () in
  26. print("ERROR: \(fault!.message)")
  27. })

Regards, Olga

photo
1

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 ?

photo
1

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