I am running through the “Clone Portal users, groups and content” sample notebook and I am running into a few issues. My source is an AGOL Subscription and target is a 60 day trial subscription.
1. When I try the copy_user(target, user, ‘TestPassword@123′), it does not want to create the new user (HTTPError: HTTP Error 404: Not Found).
2. When I try and copy the group (tgt_group = copy_group(target, source, group)) I get a runtime error (RuntimeError: Unable to reassign group.
You already have a group named ‘Admin Tools for AGOL’. Try a different name.
(Error Code: 400))
It seems as though the problem is if the target portal is a 60 day trial. I went from the 60 day trial to my on-premise portal and it ran fine.
Am I doing something wrong here?
Thanks
Julian.
Hello Julian,
You aren't doing anything wrong. I checked and found out that the add users functionality in the API currently only works with a Portal and not with ArcGIS Online orgs. This is something we should fix - I've made a note of this in our issues database and hope to have a fix in the next update.
Thanks,
Rohit
rsingh-esristaff This may have saved me from putting in a post this morning. +1 for getting it to work in AGOL too.
We are just starting on testing Portal, but our org's AGOL account has been around for a few years and is very messy. In my case, I was testing the "Move existing user content to a new user" sample as demo'd in one of the Dev Summit sessions.
I've getting my expected results in Jupyter Notebook for the "gis.users.create" section (and DO NOT do not see a 404 error), but the new user does not show in our AGOL. When I do the "item.reassign_to(new_userid)" section, that is where I get my "You do not have permissions to access this resource or perform this operation" error.
Is this related to the same bug? Or should I post a new question or tech support ticket?
Please note that this bug was fixed in version 1.0.1 released in February. See release notes:
https://developers.arcgis.com/python/guide/release-notes/
The level parameter was added to gis.users.create() call - http://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.html#arcgis.gis.UserManager.create
Thanks. I do have the latest 1.0.1. I will check my process again and put in a support ticket if needed.
@Rebecca I'll look into the other issue you reported with Item.reasssign_to() and get back.
thanks. BTW, I test with the added level = 2 (and tried level = '2') but same results.
Comment re: help. You may want to mention what the default is for "level" is you don't add that to your arguments. Since the "original" users (before the level 1/2 designation) all converted to Level 2, many of us do not (and maybe never will) have level 1 users. ...seersingh-esristaff 's response below....I did see that but didn't click in my brain at the moment.
re: the item.reassign_to() not sure if it is that line, or the entire block that is causing the issue
usercontent = olduser.items()
folders = olduser.folders
for item in usercontent:
try:
item.reassign_to(new_userid)
except:
print(item)
for folder in folders:
gis.content.create_folder(folder['title'], new_userid)
folderitems = olduser.items(folder=folder['title'])
for item in folderitems:
item.reassign_to(new_userid, target_folder=folder['title'])
I didn't mean to high-jack this thread. I can spin this off if you think that is appropriate.
edit: btw VERY new to Python API (just started this week, after Dev Summit exposure)
The default level is level 2. It's mentioned in the method signature in the api doc at arcgis.gis module — arcgis 1.0.1 documentation
create
(username, password, firstname, lastname, email, description=None, role='org_user', provider='arcgis', idp_username=None, level=2)
@Rebecca I looked into the issue and it seems to me that your AGOL org is not configured to use a different identity provider such as SAML or IWA that this sample assumes.
The gis.users.create() call is failing for probably this reason, and it would be returning you a None newuser that you can confirm by print(newuser) after this call.
You could create a new user by replacing the code in there with the following:
newuser = target.users.create(new_userid, "pwdN55otUsed", olduser.firstName, olduser.lastName, \ new_userid, description=olduser.description, role=olduser.role)
then print(newuser) to confirm it is not None and proceed forward.
The reassign_to call is failing because the user isnt getting created for some reason.
it seems to me that your AGOL org is not configured to use a different identity provider such as SAML or IWA that this sample assumes.
you are correct. We are not using SAML or IWA. I had already removed the
, provider='enterprise', idpUsername=None
part of the command, and have played with adding the email, and level. Using print(newuser) or type(newuser) does produce info....not "None", null, or anything else that makes it look like it didn't work.
type(newuser) returns
Which makes it look like it works. I'm able to do many other queries with my connection, which is an Administrator. Of course, I am just reading most things. The createuser gives me now error that I can see (not in the dev window either) but it never shows in my org account ...and the other error mention when trying to move things. My guess is the move isn't working since the new user never shows.