Updating Data Object Relations With Existing Objects - iOS Swift

Basically, I have table called Game, which contains two other Data (away team, home team).
away team and home team are Data Object Relationships from Game table to Team table.
suppose I have team1, team2 already in Team table and I want to add a new game object referencing those two teams, how can I do that?. The documentation aren’t helpful for this matter.

Here is my code

let team = (self.league.teams?.objectAtIndex(0) as! Team)

       //retrieved two teams from backendless

        let team = (self.league.teams?.objectAtIndex(0) as! Team)

        let team1 = (self.league.teams?.objectAtIndex(2) as! Team)

        //create new game object

        let game1: Game = Game()

        game1.homeTeam = team

        game1.awayTeam = team1

        game1.gameDate = NSDate()


        var error: Fault?

        let result = backendless.data.save(game1, error: &error) as? Game

        if error == nil {

            print("game1 havs been saved: \(result)")


        else {

            print("Server reported an error: \(error)")


When I run the above code, I get duplicate key error.
It is a bit urgent.

Could you please post the error you’re getting?

This is the error I get,

Server reported an error: Optional(FAULT = ‘1155’ [Duplicate entry] <Duplicate entry> )


Could you please download the latest SDK, update the libraries in your project and try again?