Question is essentially the title: is it possible to create accounts using the python api that's a replication of the 'Add members and notify them via email' style used in the GUI (see below)?
Our workflow is going to involve ingesting a list of hundreds of names from a survey, verifying them, and then creating hub community accounts. The preference would be to do so in a way that lets the user set their own password rather than provisioning them one.
I've been able to create users just fine, and then send a notification email just fine, but I don't like how the process is separate and the fact that a notification email comes from me, rather than the ArcGIS Online system. Examples below:
#Define User
first_name = 'First'
last_name = 'Last'
email = 'First.Last@fake.com'
#Create user
new_user = gis.users.create(
username = f'{first_name}_{last_name}_Community',
password = 'testTest123',
firstname = first_name,
lastname = last_name,
email = email,
credits = 50,
role = 't8qahvxvKEh6uNyT',
user_type = 'creatorUT',
groups = '<987ce15a07694fa6bf9ec45cd6241b7b>'
)
#Send notification
userList = []
userList.append(new_user)
messageSubject = 'This is a test message from AGOL'
messageMessage = 'This is the plain text message that we are sending. Check it out.'
gis.users.send_notification(userList, subject = messageSubject, message = messageMessage, type = 'email')
It would seem that just using the .create() method could generate the GUI-style email, as, according to the documentation, there's an 'email_text' argument (see below). However, when attempting this I get an error saying that the 'email_text' argument is unexpected.
create(username, password, firstname, lastname, email, role, description=None, provider='arcgis', idp_username=None, level=2, thumbnail=None, user_type=None, credits=- 1, groups=None, email_text=None)¶
emailText = 'This is a test email! You have been invited to join this community extravaganza!'
new_user = gis.users.create(
username = f'{first_name}_{last_name}_fhsz',
password = 'testTest123',
firstname = first_name,
lastname = last_name,
email = email,
credits = 50,
role = 't8qahvxvKEh6uNyT',
user_type = 'creatorUT',
groups = '<987ce15a07694fa6bf9ec45cd6241b7b>',
email_text = emailText
)
Any help would be appreciated. It would be much better if we could mimic the GUI-style sending of an email, rather than creating the usernames and then sending them an email to try to log in.
Wonder if you might be using a pre-2.2.0 version of the ArcGIS for Python API, which would not include the email_text parameter? (What's new in version 2.2.0?)
@PeterKnoop You were right. After faffing through upgrading Pro, getting my python environments switched out (since Pro wouldn't accommodate updating my previous ones), I now have the updated 2.2 version of the arcgis module which allows the email parameter.
So far it successfully created the account but there's not an email in sight. So I revert to my original question: is something like 'add members and notify via email' possible?
Did you this to work?
I am using 2.3.0.3 and no email is sent.
Is there a setting in the portal that needs to be flipped?
What just worked for me was: