[Possible Bug] User Provisioning update primaryTeamId without providing roleId

Hi Team,

I’m looking to use the User Provisioning API and have run into what appears to be a bug that causes the role of an account to be removed when not including the roleId param during an update.

When I make the following call, the user’s primary team is updated but their role is removed.

PUT /users/{userId}
{“primaryTeamId”: “101”}

When I make the following call, the user’s role is updated and their primary team unchanged.

PUT /users/{userId}

{“roleId”: “100”}

This behaviour with roleId isn’t mentioned in the documentation and is inconsistent with the other parameters available for updating which is why I believe this is a bug.

Has anyone else run into this issue?

Hey, @MKnight :waving_hand: Thanks for reaching out. A few questions to help get the ball rolling:

  • You are updating existing users?
  • You are using the example from the page here? Modifies a user
  • Can you add your full request and response body here? I’d like to reproduce this exactly as you are doing it, if possible

Thank you! — Jaycee

Hi Jaycee,

I’ve put together the test I’ve run to reproduce this issue. There appears to have been a change to the API since I last ran this. I’m no longer getting the secondaryTeamIds property and am instead getting a roleIds property. But this hasn’t changed the outcome of my testing.

curl --request GET \
--url https://api.hubapi.com/settings/v3/users/49115683 \
--header 'authorization: Bearer pat-***'

response:
{
 "id": "49115683",
 "email": "***",
 "roleId": "525394",
 "roleIds": [
 "525394"
 ],
 "primaryTeamId": "14045993"
}

###

curl --request PUT \
--url https://api.hubapi.com/settings/v3/users/49115683 \
--header 'authorization: Bearer pat-***' \
--header 'Content-Type: application/json' \
--data '{"primaryTeamId": "14045992"}'

response:
{
 "id": "49115683",
 "email": "***",
 "roleIds": [],
 "primaryTeamId": "14045992"
}

###

curl --request GET \
--url https://api.hubapi.com/settings/v3/users/49115683 \
--header 'authorization: Bearer pat-***'

response:
{
 "id": "49115683",
 "email": "***",
 "roleIds": [],
 "primaryTeamId": "14045992"
}

###

curl --request PUT \
--url https://api.hubapi.com/settings/v3/users/49115683 \
--header 'authorization: Bearer pat-***' \
--header 'Content-Type: application/json' \
--data '{"roleId": "525394"}

response:
{
 "id": "49115683",
 "email": "***",
 "roleId": "525394",
 "roleIds": [
 "525394"
 ]
}

###

curl --request GET \
--url https://api.hubapi.com/settings/v3/users/49115683 \
--header 'authorization: Bearer pat-***'

response:
{
 "id": "49115683",
 "email": "***",
 "roleId": "525394",
 "roleIds": [
 "525394"
 ],
 "primaryTeamId": "14045992"
}

I can also see in the UI that the account is listed with “No Permission Set” after running the intial PUT and comes back after the last call