An issue when trying list public objects in Unity

Documentation says:

‘You can list objects in a collection and page through results. The objects returned can be filter to those owned by the user or “null” for public records which aren’t owned by a user.’

I have stored objects in a collection with PermissionRead = 2 and PermissionWrite = 1 but when I try to list the collection I get:

a) no results if I set userId to session.userId
b) “ArgumentException: ‘userId’ is required but was null” if I set userId to null
c) “ApiResponseException: Invalid user ID - make sure user ID is a valid UUID.” if I set userId to “null”

Documentation say that you should use u null or string “null” to get the public objects but doing so just generates exceptions.

Is this a bug in the system or should I do this in some other way?

Listing:

string user = client.UserId or null or “null”
var result = await client.ListUsersStorageObjectsAsync(session, “MyCollection”, user, 100);

Inserting:

var objectIds = await client.WriteStorageObjectsAsync(session, new WriteStorageObject
{
Collection = “MyCollection”,
Key = “Something”,
Value = “TheData”,
PermissionRead = 2,
PermissionWrite = 1
});

Nakama Unity plugin version is 2.5.1.

Solved this myself. Instead of passing null to userId you can use ListStorageObjectsAsync instead of ListUsersStorageObjectsAsync.

3 Likes