Select to view content in your preferred language

Error creating a user with custom role

1821
3
09-13-2018 09:18 PM
NareshAligeti2
Emerging Contributor

I get an error when I execute my script to create a user with a custom role. Level 2 is assigned as well to the user but no luck executing the code successfully.

java.lang.Exception:
The server at 'https://XXXXXXXXXXXXX.XXXXXXX.com:7443/arcgis/sharing/rest/community/createUser' returned an error. The user account cannot be created as the role assigned to it does not exist. []
(Error Code: 500)

But the custom role exists when I see logging in as an admin through the UI.

Can I get some help? Thanks.

Atma Mani

-Naresh Aligeti

python api portal‌

arcgis-api-python‌

3 Replies
by Anonymous User
Not applicable

One way to investigate this is to list the custom roles using Python, then using that as an input when you create a new user. This avoids typos and aliases if there are any.

You can look up at Accessing and managing users | ArcGIS for Developers for how to list custom roles.

NareshAligeti2
Emerging Contributor

Mani,

Thanks for your prompt reply. I found a fix (probably a bandage fix).

We have one custom role called ViewerPlus. When I tried to add the user from backdoor(script) it fails but adding the same user to the same role through front end(UI) works just fine, upon looking at the form data using fiddler trace i found that role is submitted to portal as daiG7yglgzR6cnLe. 

When I change the code by assigning the role variable to daiG7yglgzR6cnLe, it works fine. 

This is not just happening to a custom role but also a default role that esri provides.

On the other hand, documentation says "org_admin" but UI form passes it as "account_admin". I use "org_admin" in my code and it works just fine.

Don't you think this is a bug?

-Naresh Aligeti

JCGuarneri
Frequent Contributor

Thanks for this! This will save me a lot of time. As an FYI for others stumbling on this post, I discovered that if you filter your users by the custom role of interest, the ID will show in the URL bar:

JCGuarneri_0-1651069610662.png