Select to view content in your preferred language

Can I use the ArcGIS REST API createUser in AGOL?

600
2
05-05-2020 07:30 AM
MichaelHancock
Emerging Contributor

Something like

I do get back a 200 OK but the account is not created ...

I'm trying to create a hub community user so they can take a survey but we don't want them to have to go through the esri login pages (branding issue)

Thanks in advance  

Tags (1)
0 Kudos
2 Replies
BenTurrell
Frequent Contributor

Hey Michael Hancock‌,

I'm not super familiar with the REST API for ArcGIS Online however are you doing this with a POST or GET? I believe you will need to POST the data.

You can also use python which is my preferred way of doing this sort of thing:

from arcgis.gis import GIS
gis = GIS("portal url", "username", "password")
new_user = gis.users.create(username = 'miketest42',
                              password = 'test1234',
                              firstname = 'Mike',
                              lastname = 'Test',
                              email = 'miketest41@gmail.com',
                              description = 'Demonstrating how to create users using ArcGIS Python API',
                              role = 'org_user',
                              level = 1,
                              provider = 'arcgis')

You should just need to update the bits in red. The python API uses the REST API but it has better documentation and lots of examples!

Thanks,

Ben


If this answer was helpful please mark it as helpful. If this answer solved your question please mark it as the answer to help others who have the same question.

MichaelHancock
Emerging Contributor

Thank you Ben, yes I am using POST and  using a token in the authentication header (OAuth 2.0)

I will try the Python API ... is there also a JavaScript API ?

Second part to my question: Is there a way to redirect our uses to our hub site and log them in?

I was hoping something like 

would work but it just appears to hang on the rotating square ...

Is this even possible?

Appreciate any further input

Thanks

0 Kudos