Select to view content in your preferred language

How to change the User License Type using REST API?

2150
9
Jump to solution
06-01-2022 05:19 PM
Thomas_Z2
Regular Contributor

How can I change the User License Type using the REST API? I searched unsuccessful for an endpoint, I suspect there should be something similar like these endpoints:

0 Kudos
1 Solution

Accepted Solutions
Thomas_Z2
Regular Contributor

Thank you @JohnPlunkett but I was looking for this:

  • /portals/self/updateUserLicenseType

and it looks like it exists but it is undocumented.

Here my findings in case someone else has a similar use case:

View solution in original post

9 Replies
JohnPlunkett
Esri Contributor

Is this what you are after? 

portal/sharing/rest/portals/0123456789ABCDEF/updateUserRole

0 Kudos
Thomas_Z2
Regular Contributor

Thank you @JohnPlunkett but I was looking for this:

  • /portals/self/updateUserLicenseType

and it looks like it exists but it is undocumented.

Here my findings in case someone else has a similar use case:

Marc_Graham
Frequent Contributor

Thanks so much for updating this thread with what you found. 😀

0 Kudos
GarethFinney1
Occasional Contributor

Hi there @Thomas_Z2 

I saw your posting on the updateUserLicenseType Rest API call, and was wondering if you would mind sharing a code snippet of sorts to help me out here. I've been trying to find the way to update a user on the fly via the back-end, and this seems to be the way to do it - and as you've mentioned, Esri have not really documented anything about it! 

I've tinkered with the url request  ../arcgis/sharing/rest/portals/self/updateUserLicenseType?... but I'm yet to find a valid url that actually works.

I'll also take a look at the Python approach you've mentioned, but I'd rather hit it with a Rest call to be honest.

Any help truly appreciated (in either Rest, or Python cases)

thanks in advance

Gareth

0 Kudos
Marc_Graham
Frequent Contributor

Hi Gareth,

I have created a workflow in FME that allows users to "check out" or "return" a license without having to ask an administrator.  The workflow requires us to update the role and the license type in two steps. there are two options - if the user checks out a license I set their named user to fieldWorkerUT and the corresponding custom role and if the user returns a license I set them to viewerUT and the corresponding custom viewer role.

First update License Type:

Request URL: $(arcgis_portal_url)/$(arcgis_portal_webadaptor_context)/sharing/rest/portals/0123456789ABCDEF/updateUserLicenseType

Method: POST

Parameters:

  • token: token
  • users: $(portal_username)
  • f: pjson
  • userLicenseType: $(new_user_type)

new_user_type = fieldWorkerUT or viewerUT

Second update User Role:

URL: $(arcgis_portal_url)/$(arcgis_portal_webadaptor_context)/sharing/rest/portals/0123456789ABCDEF/updateUserRole

Method: POST

Parameters:

  • token: token
  • users: $(portal_username)
  • f: pjson
  • role: $(new_role)

new_role = 7Wqt2kdDEMSska9w or 3Fg8KwpdZknhNZE6 depending upon which one matches the license type that was selected first.

MarcGraham2_0-1684802617488.png

 

I hope this helps,

Marc

0 Kudos
GarethFinney1
Occasional Contributor

Hi Marc,

thanks for the speedy reply - much appreciated.  I'll give it a try, but I'm actually starting to think I may need to update the portal, from 10.7.x  I can't see the /updateUserLicenseType method on the /arcgis/sharing/rest/portals/self endpoint. Can you please confirm this, if running a newer version of Portal?  

thanks again

Gareth

0 Kudos
Marc_Graham
Frequent Contributor

EDIT: Oh I see that is a slightly different endpoint in the documentation. I still confirmed it is there at 10.7 in our old portal:

MarcGraham2_0-1684803877022.png

 

It should be there - according to the docs it was introduced at 10.7: https://developers.arcgis.com/rest/users-groups-and-items/user-license-types.htm

I can confirm that on our deprecated 10.7 portal it is there.

 

0 Kudos
Marc_Graham
Frequent Contributor
0 Kudos
GarethFinney1
Occasional Contributor

yeah cool.. I see it now -  just needed to scroll down to the bottom of the page - doh!

thanks for your help on this, much appreciated

0 Kudos