I am trying to copy an item from one portal to another. I've written about the use case in another question.
I have some code like this. Forget about my use case above. Here I am simply trying to add a item to a folder and then publish it.
item_properties = {
'title': itemTitle,
'type': 'File Geodatabase',
'description': item.description,
'accessInformation': item.accessInformation,
'licenseInfo': item.licenseInfo,
'overwrite': True
}
# to ensure no prev items can exist in same spot
folder_name = f"_testing_{item_properties['title']}_{str(uuid.uuid4())[:4]}"
# create new folder to hold
new_folder = trg.content.folders.create(folder_name)
fgd = new_folder.add(item_properties=item_properties, file=download_result).result()
targetService = fgd.publish(overwrite=True) I get the error. It appears to be associated with Publish. It is impossible for me to parse what it means:
Exception('Unable to Add messages Job Event\nUnable to Add messages Job Event\n(Error Code: 500)'),) Stack trace
targetService = fgd.publish(overwrite=True)
--- Logging error ---
Traceback (most recent call last):
File "C:\Users\me\code\source\repos\arcgis-cloner\src\service_app.py", line 105, in copy_layer_to_folder
targetService = fgd.publish(overwrite=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\me\.virtualenvs\arcgis-cloner-pO5T1BLr\Lib\site-packages\arcgis\gis\__init__.py", line 16273, in publish
return job.result()
^^^^^^^^^^^^
File "C:\Python312\Lib\concurrent\futures\_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "C:\Python312\Lib\concurrent\futures\_base.py", line 401, in __get_result
raise self._exception
File "C:\Python312\Lib\concurrent\futures\thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\me\.virtualenvs\arcgis-cloner-pO5T1BLr\Lib\site-packages\arcgis\gis\__init__.py", line 16550, in _publish
ret = self._portal.publish_item(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\me\.virtualenvs\arcgis-cloner-pO5T1BLr\Lib\site-packages\arcgis\gis\_impl\_portalpy.py", line 509, in publish_item
resp = self.con.post(path, postdata, files)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\me\.virtualenvs\arcgis-cloner-pO5T1BLr\Lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 1504, in post
return self._handle_response(
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\me\.virtualenvs\arcgis-cloner-pO5T1BLr\Lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 979, in _handle_response
self._handle_json_error(data["error"], errorcode)
File "C:\Users\me\.virtualenvs\arcgis-cloner-pO5T1BLr\Lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 1002, in _handle_json_error
raise Exception(errormessage)
Exception: Unable to Add messages Job Event
Unable to Add messages Job Event
(Error Code: 500)If I remove the overwite=True then publish does not work at all since an unpublished version is created in the same folder during this process, and so I get the error:
Arguments: (Exception({'message': "Service name 'MyServkce' already exists for '1234abcd'"}),)I've tried to downgrade to arcgis==2.0.0 from 2.4.0 but the error persists.
How can I solve this error?