Getting KeyError as "assignments" when using workforce with geoprocessing tool.

352
9
11-30-2021 09:50 PM
UğurcanGül
New Contributor II

Hello,

I published a toolbox that works in local server but i could not make it work as a geoprocessing tool.

My idea is that i want to be able to reach to workforce through using ArcGIS API and want to make operations over there by using the tool i created. It works without a problem on the ArcGIS Pro, but when i publish it as a geoprocessing device i get the following error.

 

Traceback (most recent call last): File "", line 71, in execute File "C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\apps\workforce\project.py", line 45, in __init__ self._assignment_schema = AssignmentSchema(self.assignments_layer) File "C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\_impl\common\_utils.py", line 158, in _lazy_property setattr(self, attr_name, fn(self)) File "C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\apps\workforce\project.py", line 233, in assignments_layer return FeatureLayer(self.assignments_layer_url, self.gis) File "C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\apps\workforce\project.py", line 183, in assignments_layer_url return self._item_data['assignments']['url'] KeyError: 'assignments' Failed to execute (Tool). Failed to execute (Tool). Failed.

0 Kudos
9 Replies
ABishop
Regular Contributor II

Hello,

Could you try publishing it as a geoprocessing service?  Looks like the "assignments" are pointing to the server.  

Amanda Bishop, GISP
UğurcanGül
New Contributor II

Hey,

I published it as a geoprocessing service. It worked as a tool however when i add the geoprocessing service to a webapp it gives me the error as  

"C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\apps\workforce\project.py", line 183, in assignments_layer_url return self._item_data['assignments']['url'] KeyError: 'assignments' Failed to execute (Tool). Failed to execute (Tool). Failed." 

I have an enterprise license where i publish the tool but it does not have workforce license in it . I try run the geoprocessing server on the web app on another license which has workforce license. Could that be the reason?

0 Kudos
ABishop
Regular Contributor II

I don't think the licensing is an issue, but you could try testing it with another license with workforce.

Another thing to pay attention to is when the geoprocessing tool works... where are you running it from?  It could have to do with permissions in the web app using a browser?

Amanda Bishop, GISP
UğurcanGül
New Contributor II

I use Chrome as my main browser. I tried running it on Mozilla still no luck so far.

0 Kudos
ABishop
Regular Contributor II

so when it works you are running it from chrome on your PC with your login?

Amanda Bishop, GISP
UğurcanGül
New Contributor II

I think i could not make my self clear enough. I run the toolbox from ArcGIS Pro and it works without a problem but if i publish it as a geoprocessing service it does not work. I tried it by using chrome and mozilla but they did not do the trick. I cannot access the assignment layer from online when i run the geoprocessing server.

ABishop
Regular Contributor II

Try publishing the assignment layer in your online account.  Then build the geoprocessing tool from the published assignment layer.

Amanda Bishop, GISP
UğurcanGül
New Contributor II

But it is a workforce project I created in workforce apps. The assignment layer is already inside of the app. It gets created automatically. 

0 Kudos
ABishop
Regular Contributor II

OK... not sure how that works.  It was just a suggestion to see if maybe the issue was from a permissions error with the assignment layer.

Amanda Bishop, GISP
0 Kudos