How to create an entity in a Collection [Unity]

Before we can create an entity in a collection two things are needed.

1) The collection has to exist. That means the admin of the game needs to create it beforehand in the Gamedonia Dashboard. After that, each user will be able to manage entities in the collection depending on the permissions established when creating it.

If the collection doesn't exist yet, the call to Gamedonia API will return a "400 Bad Request, Collection does not exist." message.

2) You need to start a Gamedonia session for a user first. All the operations regarding the Data API must be executed on behalf a Gamedonia user. That means you have to login a specific user before creating an entity. You can use any of methods described in the Users guide to login the user. If you still have no user registered in your game, you should create one.

If you try to create an entity without an open Gamedonia session, you will get a message like this:

NullReferenceException: Object reference not set to an instance of an object
GamedoniaUsers.GetSessionToken () (at Assets/Plugins/Gamedonia/GamedoniaUsers.cs:26)
GamedoniaData.Create (System.String collection, System.Collections.Generic.Dictionary`2 entity, System.Action`2 callback) (at Assets/Plugins/Gamedonia/GamedoniaData.cs:19)

To create an entity correctly, you should do something like this:

GamedoniaUsers.LoginUserWithEmail("the_email", "the_password", delegate (bool success){
   if (success){
      // Store all the information you want inside a dictionary
      Dictionary<string,object> movie = new Dictionary<string,object>();
      movie["name"] = "The Godfather";
      movie["director"] = "Francis Ford Coppola";
      movie["duration"] = "178 minutes";
      movie["music"] = "Nino Rota";
      // Make the request to store the entity inside the desired collection
      GamedoniaData.Create("movies", movie, delegate (bool success, IDictionary data){
          if (success){
             // entity was created successfully
             // create failed, collection doesn't exist?
    else {
       // login failed, the user doesn't exist?

More info here: Data storage guide