Give manager role/rights to project member by API

Hi all. I am trying to set the “project manager” role for one of the project members in a project I have just created. I use this endpoint: https://api.clockify.me/api/v1/workspaces/{workspaceId}/users/{userId}/roles
And with body:
{
“entityId”: “id of just created project”,
“role”: “PROJECT_MANAGER”,
“sourceType”: “USER_GROUP”
}
But I received message: “Roles were not updated because source is only applicable to TEAM_MANAGER role”. I don’t know why is this happening because when I try change this role by UI (using the same user I have in the token) - everything works fine.

Do you have any idea what is wrong?

Hello Marcin,

The “sourceType” key refers to users who would be managed by the team manager. Project managers deal with projects, so you could leave out the “sourceType”: “USER_GROUP” from your request.

Your body could look like this:
{
“entityId”: “enter projectId here”,
“role”: “PROJECT_MANAGER”
}

I hope this helps.

Have a nice day!

Hi Aleksandar,
yes, it works!
Thank you very much!!!
Marcin