Using the API to add new links using only _id

Hi all!

I have 2 collections :

Collection A {
  String groupName;
  CollectionLink<Collection B> users;
}

When I add a new user using the API with a request like :

{
    "data": {
        "_id": "idOfTheCollectionAIWantToUpdate",
        "users": [
            {
                "_id": "IdOfAUserIWantToAdd"
            }
        ]
    }
}

I can see that the request worked because cockpit recognizes the new user on the web interface. But when I use the cockpit’s API to get the edited collection, cockpit gives me a JSON with only the user’s ID :

Collection A {
    "groupName": "AwesomeName",
    "users": [
        {
            "_id": "IdOfAUser"
        }
...

When I want something like :

...
Collection A {
    "groupName": "AwesomeName",
    "users": [
        {
            "_id": "IdOfAUser",
            "username": "MyAwesomeUserUsername",
            "email": "email@....",
            // all the other fields of the user
        }
...

Is it possible to achieve this ?
Thank you ! :slight_smile:

You have to use populate to view all fields. Add ?populate=1 after the URL and it should work.
e.g

https://[your_domain]/api/collections/get/[your_collection]?token=[your_token]&populate=1