I am trying to access a Workforce project (new version) using the ArcGIS API for Python. I have upgraded ArcGIS Pro to version 2.6, cloned the default environment, and updated the arcgis package to 1.8.2.
Here is my code:
<SPAN class="keyword token">import</SPAN> arcgis
org_url <SPAN class="operator token">=</SPAN> <SPAN class="string token">'orgurlhere'</SPAN>
un <SPAN class="operator token">=</SPAN> <SPAN class="string token">'myUn'</SPAN>
pw <SPAN class="operator token">=</SPAN> <SPAN class="string token">'myPw'</SPAN>
itemId <SPAN class="operator token">=</SPAN> <SPAN class="string token">'itemid'</SPAN> <SPAN class="comment token">#Service ItemId</SPAN>
gis <SPAN class="operator token">=</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>gis<SPAN class="punctuation token">.</SPAN>GIS<SPAN class="punctuation token">(</SPAN>org_url<SPAN class="punctuation token">,</SPAN>un<SPAN class="punctuation token">,</SPAN>pw<SPAN class="punctuation token">)</SPAN>
item <SPAN class="operator token">=</SPAN> gis<SPAN class="punctuation token">.</SPAN>content<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN>itemId<SPAN class="punctuation token">)</SPAN>
project <SPAN class="operator token">=</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>apps<SPAN class="punctuation token">.</SPAN>workforce<SPAN class="punctuation token">.</SPAN>Project<SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
I get the following error:
Traceback (most recent call last):
File "C:\myscripts\test_wf.py", line 11, in <module>
project = arcgis.apps.workforce.Project(item)
File "C:\Users\myun\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone2\lib\site-packages\arcgis\apps\workforce\project.py", line 45, in __init__
self._assignment_schema = AssignmentSchema(self.assignments_layer)
File "C:\Users\myun\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone2\lib\site-packages\arcgis\_impl\common\_utils.py", line 158, in _lazy_property
setattr(self, attr_name, fn(self))
File "C:\Users\myun\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone2\lib\site-packages\arcgis\apps\workforce\project.py", line 233, in assignments_layer
return FeatureLayer(self.assignments_layer_url, self.gis)
File "C:\Users\myun\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone2\lib\site-packages\arcgis\apps\workforce\project.py", line 183, in assignments_layer_url
return self._item_data['assignments']['url']
KeyError: 'assignments'
I am just starting out with the ArcGIS API for Python but this seems pretty basic. Does anyone have any ideas what might be wrong here?