Can't create entity - getting Error 1020

Error Message:

Server reported an error: Optional(FAULT = ‘1020’ [Missing ___class property for entity: member] <Missing ___class property for entity: member> )

I want to save a new object which includes an array of BackendlessUsers. The current user is added to this object. Unfortunately I get the above mentioned error.

Anything else what you need here?

Thanks,
Norman

Do you use the JS library or making a REST call? In either case, please show what the request looks like.

Regards,
Mark

I am using the iOS SDK:

let user = self.backendless?.userService.currentUser
let selectedCompetition = allCompetitions[self.pickerView.selectedRow(inComponent: 0)]



        


let communityItem = Community(

                name: self.nameOfCommunityTextField.text!,

                welcomeText: self.welcomeTextBox.text!,

                members: [user!],

                pointsExact: Int(self.pointsExactTextField.text!)!,

                pointsTendency: Int(self.pointsTendencyTextField.text!)!,

                pointsResult: Int(self.pointsResultTextField.text!)!,

                admin: user!,

                competition: selectedCompetition,

                objectId: ""

            )

        

            let dataStore = self.backendless?.data.of(Community.ofClass())

            

            var error: Fault?

            let result = dataStore?.save(communityItem, fault: &error) as? Community

            

            if error == nil {

                print("Contact has been saved: \(result!.objectId)")

                self.createdCommunity = result! as Community //.objectId!

                dismiss(animated: true, completion: nil)

            }

            else {

                //TODO: getting: Server reported an error: Optional(FAULT = '1020' [Missing ___class property for entity: member] &lt;Missing ___class property for entity: member&gt; )

                //[url=http://support.backendless.com/t/cant-create-entity-getting-error-1020]http://support.backendless.com/t/cant-create-entity-getting-error-1020[/url]

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

                displayAlertWith("A problem occured, please try again later.")

            }

A couple of questions for you:

    Is there "members" column in the Community table on the server? If so, is it declared as a relation column? Is it one to one or one to many? Is the "user" object a non-null value? Have you checked in a debugger? not really a question, more an observation: I'd set objectId to nil rather than sending an empty string.
Regards, Mark

Thanks for your reply Marc:

  1. Yes, indeed - One (Community) to Many (Member)
  2. Yes, not nil
  3. Thanks for that, changed.

Does the “members” column point to the Users table or the Member table?

That would be the “Users” table

Thanks! I am sorry if it looks like I am giving you the runaround, I should’ve asked in the first place: did you make sure you have the latest build of our SDK? Did you install through Cocoapods or downloaded it from the website?

Finally, does the call go through if you exclude the “members” property from the call and leave only “admin” (which is also a relation to the Users table).

I know the struggle Mark as I am also working in a client facing role. I am super thankful, that you guys are so helpful!

I updated via cocoa pods 2-3 days ago.

Interestingly, when I comment out the member variable I still receive the same error message…

Server reported an error: Optional(FAULT = ‘1020’ [Missing ___class property for entity: member] <Missing ___class property for entity: member> )

That’s very odd. Is there perhaps a property called “member” within the BackendlessUser object which you send back to the server?

Can you please elaborate on this? I do not have my own User class defined within the project. I just read the currentUser object and assign it to the Community class.

An object representing a user is a collection of properties defined as key/value pairs. My question is whether there is a property named “member” in the object representing the current user.