Backendless Support
 
Solved

Error 3017 when trying to update user properties

Hello,

I'm new iOS developper with Backendless and I've actually a problem, when I'm connected on my application with admin user and when I'm trying to update the properties of an other user, there is this error :

  1. Server reported an error (1): Optional(FAULT = '3017' [User property with name 'lastLogin' already exists.] <User property with name 'lastLogin' already exists.> )

It's my code:

  1. func toggleAgent(sender: String, agent: BackendlessUser, completion: @escaping (_ result: String) -> Void) {
  2. let user = agent
  3. var props:[String: Bool] = [:]
  4. if(sender == "tapActivateAgent") {
  5. props = [
  6. "status" : true
  7. ]
  8. }
  9. else if(sender == "tapDesactivateAgent") {
  10. props = [
  11. "status" : false
  12. ]
  13. }
  14. backendless?.userService.registering(user,
  15. response: { (registeredUser : BackendlessUser?) -> Void in
  16. print("User has been updated (ASYNC): \(registeredUser)")
  17. let properties = props
  18. registeredUser!.updateProperties( properties )
  19. self.backendless?.userService.update(registeredUser,
  20. response: { ( updatedUser : BackendlessUser?) -> Void in
  21. print("Updated user: \(updatedUser)")
  22. },
  23. error: { ( fault : Fault?) -> Void in
  24. print("Server reported an error (2): \(fault)")
  25. })
  26. },
  27. error: { ( fault : Fault?) -> Void in
  28. print("Server reported an error (1): \(fault)")
  29. }
  30. )
  31. }

In advance, thanks.

Leave a Comment

Comments (3)

photo
1

Hey Fafab

I've contacted with our iOS developer

He will help you as soon as possible

Regards, Vlad

photo
1

Hi Vladimir, thank you for your help. I'm waiting his response.

photo
photo
1

Ok, solved with this code :

  1. func toggleAgent(sender: String, agent: BackendlessUser, completion: @escaping (_ result: String) -> Void) {
  2. let user = agent
  3. if(sender == "tapActivateAgent") {
  4. user.setProperty("status", object: true)
  5. }
  6. else if(sender == "tapDesactivateAgent") {
  7. user.setProperty("status", object: false)
  8. }
  9. // save object asynchronously
  10. let dataStore = backendless?.data.of(BackendlessUser.ofClass())
  11. dataStore?.save(
  12. user,
  13. response: { (result: Any?) -> Void in
  14. let obj = result as! BackendlessUser
  15. print("User has been updated: \(obj.objectId)")
  16. completion("Modifications effectuées.") //appel closure/call-back
  17. },
  18. error: { (fault: Fault?) -> Void in
  19. print("Server reported an error: \(fault)")
  20. })
  21. }