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 :

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:

    func toggleAgent(sender: String, agent: BackendlessUser, completion: @escaping (_ result: String) -> Void) {


        
        let user = agent


        var props:[String: Bool] = [:]
        
        if(sender == "tapActivateAgent") {
            props = [
                "status" : true
            ]
        }
        else if(sender == "tapDesactivateAgent") {
            props = [
                "status" : false
            ]
        }
        
        backendless?.userService.registering(user,
                                            response: { (registeredUser : BackendlessUser?) -> Void in
                                                print("User has been updated (ASYNC): \(registeredUser)")
                                                
                                                let properties = props


                                                registeredUser!.updateProperties( properties )
                                                self.backendless?.userService.update(registeredUser,
                                                                                    response: { ( updatedUser : BackendlessUser?) -> Void in
                                                                                        print("Updated user: \(updatedUser)")
                                                                                        
                                                },
                                                                                    
                                                                                    error: { ( fault : Fault?) -> Void in
                                                                                        print("Server reported an error (2): \(fault)")
                                                })
        },
                                            error: { ( fault : Fault?) -> Void in
                                                print("Server reported an error (1): \(fault)")
        }
        )
    }

In advance, thanks.

Hey Fafab

I’ve contacted with our iOS developer
He will help you as soon as possible

Regards, Vlad

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

Ok, solved with this code :

    func toggleAgent(sender: String, agent: BackendlessUser, completion: @escaping (_ result: String) -> Void) {


        
        let user = agent
        
        if(sender == "tapActivateAgent") {
            user.setProperty("status", object: true)
        }
        else if(sender == "tapDesactivateAgent") {
            user.setProperty("status", object: false)
        }
        
        
        // save object asynchronously
        let dataStore = backendless?.data.of(BackendlessUser.ofClass())
        dataStore?.save(
            user,
            response: { (result: Any?) -> Void in
                let obj = result as! BackendlessUser
                print("User has been updated: \(obj.objectId)")
                completion("Modifications effectuées.") //appel closure/call-back
        },
            error: { (fault: Fault?) -> Void in
                print("Server reported an error: \(fault)")
        })
        
    }