Workforce scripts that demostrate how to use the REST API with python to administer Workforce projects
Supports Python 2.7+, 3.4+
Only Supports 'Built-in' Security
Four example scripts are provided:
- Create Assignments From CSV (Documentation)
- Copy Assignments To Feature Service (Documentation)
- Export Assignments To CSV (Documentation)
- Delete Assignments By Query (Documentation)
- Check Completion Location/Time (Documentation)
In addition, workforcehelpers.py is supplied to provide common functionality for all of the scripts. This contains:
- post(url, data) - This submits a simple POST request to the specified url with the specified data
- get(url, params) - This submits a simple GET request to the specified url with the specified data
- get_token(org_url, username, password, ...) - This authenticates the username/password with the provided organizational url
- query_feature_layer(feature_layer_url, token, ...) - This queries a feature layer for features
- get_feature_layer(feature_layer_url, token) - This gets the feature layer metadata
- get_assignments_feature_layer_url(org_url, token, projectId) - This gets the assignments feature layer url that is used by the specified project
- get_workers_feature_layer_url(org_url, token, projectId) - This gets the workers feature layer url that is used by the specified project
- get_dispatchers_feature_layer_url(org_url, token, projectId) - This gets the dispatchers feature layer url that is used by the specified project
- get_location_feature_layer_url(org_url, token, projectId) - This gets the location/tracks feature layer url that is used by the specified project
Each script requires certain parameters, however each script also requires authentication parameters. The table below summarizes the authentication parameters that each standalone script expects:
Key | Description |
---|---|
url | AGOL or Portal url |
username | username for log in |
password | password for log in |
Notes:
These scripts use Requests to easily make GET and POST requests and to support Python 2 and 3.