Using 'create assignment from csv' python script in Enterprise Portal

533
5
06-02-2021 12:22 PM
JayHodny
Occasional Contributor III

I am trying to use the 'create assignment from csv' python script for assignment creation in the new Workforce in ArcGIS for Enterprise Portal.  In the past I had been successful using this script for assignment created in Workforce in AGOL.  When I insert a headless Enterprise user account with administrative privileges, it appears the authentication fails.  When I insert my credentials, authentication appears to succeed, but then an error occurs stating my username is not a dispatcher.  The Workforce project (new not classic) has me as a dispatcher.  Any help would be appreciated.  Thank you.

5 Replies
AaronPulver
Esri Regular Contributor

Hi for the authentication issue with the admin user, can you check the case of the username? It's case-sensitive when you authenticate this way with the Python API. Either way, if that user is not a dispatcher, then they won't be permitted to make modifications using the Workforce module of the Python API.

When you load a project, all of the dispatchers are fetched and then the current users username is compared to the user_id each dispatcher - if there is no match, then you will get the exception that the current user is not a dispatcher. How are you authenticating with the script? By providing username and password or did you modify it to use an OAuth flow.

Which version of Enterprise are you using?

Which version of the Python API are you using?

0 Kudos
JayHodny
Occasional Contributor III
Hi Aaron,
We are using Enterprise 10.8.1, ArcGIS Pro 2.8.0 and whatever version of Python shipped with Pro 2.8. The create assignment script threw a Pendulum error. We cloned the Project Environment in the Python Package Manager and installed the Pendulum package, error subsided. We are running the script in the Python Command Prompt C:\.........arcgispro-py3-clone.
I will doubled check the case sensitivity on the users, as I have a vague recollection of this happening a couple of years ago.
We are providing the username and password in the command line string in the command prompt shell. Not sure how to modify it to use an OAuth flow.
Many thanks, Jay
0 Kudos
JayHodny
Occasional Contributor III

Hi Aaron, Where can I find the -custom geocoder-id values for various custom geocoders?  We have gotten past the credential issue (I think), the CSV file is read, but we now seem to be tripping over the geocoder.  If I don't include the custom geocoder parameter in the command line, I get an invalid token error.  If I include the parameter using an ID (from past work, and I have no recollection of where I found this value), the message is suggesting something to do with the geocoder.

0 Kudos
AaronPulver
Esri Regular Contributor

The customer-geocoder id is an item id to a Locator in your organization.

What is happening is that since no locator is provided, it is using the default geocoder which is the World Geocoding Service. This service requires authentication for batch geocoding because it costs credits and is hosted in ArcGIS Online. Because you are not signed into AGOL it is sending your Enterprise token which is returned as invalid. If you use your own locator in the script or change the default geocoder for your org to something that supports batch geocoding, it should work.

0 Kudos
Jcordovafredes
Occasional Contributor

Hello @JayHodny 

I want to tell you that I am making assignments from the ArcGIS ENTERPRISE account, but I have not had any error to which you mention, the only big error that I have when adding assignments with the batch_add method this throws me an error that I still cannot sort out.

I wanted to know if you have any similar error?

Greetings

 

0 Kudos