# Publish CSV to Portal: ERROR 001506

547
3
04-22-2021 11:16 AM
Labels (1)
MVP Regular Contributor

I'm getting this error when trying to publish a CSV to our Enterprise Portal v. 10.8. I'm running a stand-alone script in a Pro Python environment. The script first adds the CSV to the Portal as an item, then its intention is to publish the item as a hosted feature layer. But, it's failing when trying to publish.

The solution in the help doc for this error mentions different ways for making the data accessible to ArcGIS Server. From the solution:

If you register the containing folder, you need to explicitly give the ArcGIS Server account permissions to read from that folder.

The data is in CSV format and I have made sure the local folder where it is stored is shared with our admin account. Also, I had my colleague register the folder with the ArcGIS Server account. Am I missing something?

Full Error:

Traceback (most recent call last):
File "pathto\ArcGISPro\test.py", line 41, in <module>
pitem = item.publish(publish_parameters=pp)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\__init__.py", line 10332, in publish
res = self._portal.con.post(path, postdata)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 720, in post
force_bytes=kwargs.pop('force_bytes', False))
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 514, in _handle_response
self._handle_json_error(data['error'], errorcode)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 536, in _handle_json_error
raise Exception(errormessage)
Exception: Analyze Service error: Server tool execution failed : ERROR 001506: Failed to download the data for the portal item. Failed to execute (Analyze Features for Portal). Failed. Failed to execute (Analyze Features for Portal). Failed.
(Error Code: 0)

3 Replies
Esri Contributor

When adding a folder connection to a folder with a path like "C:\Super\Amazing\Stuff" you have to also fill out that small box asking for Publisher Folder Hostname.  Open up command prompt on the machine, and type in "hostname", then copy that value and paste it in the box mentioned above.  This may not fix your issue, but sometimes errors are hiding behind each other and it could help flush them out.

New Contributor II

Are you still running into this issue with publishing the CSV? If so, can we confirm if this error only happens with CSV files and we are able to successfully add other data as items to Portal?

If it only happens with CSV files, there is a possibility the issue may be related to the Geocoding service used in this environment if the CSV contains addresses.

Please let me know what you think.

MVP Regular Contributor

It was eventually resolved. After getting some additional help I was able to publish the CSV. I sorta lost track of all the issues I was having, but part of it turned out to be a bug: #BUG -000136260.

As much as I know, I don't think I had an issue with what you're suggesting. It had more to do with the POST request to the /additem endpoint of the Portal being redirected, which causes a JSON DecodeError. See these posts (which I'll update with the resolution tomorrow):
https://community.esri.com/t5/python-questions/publish-a-csv-to-enterprise-portal-decoding-json-has-...

https://github.com/Esri/arcgis-python-api/issues/947

I just tried publishing a xlsx file to Portal with the following script, but it also resulted in an error.

from arcgis.gis import GIS

gis = GIS('Home')

#content manager
cm = gis.content
gdb = r'path\to\Test\Test_04_21_2021.xlsx'

#create item
'type' : 'Microsoft Excel',
'typeKeywords' : 'Microsoft Excel'
},
data=gdb)

#create publish_parameters dictionary
pp={"type":"Microsoft Excel"}

pitem = item.publish(publish_parameters=pp)
print(pitem.tables)
print("---done---")

Error:

---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
In  [32]:
Line 5:     pitem = item.publish(publish_parameters=pp)

File C:\pathto\Local\ESRI\conda\envs\my-env\Lib\site-packages\arcgis\gis\__init__.py, in publish:
Line 10332: res = self._portal.con.post(path, postdata)

File C:\pathtoa\Local\ESRI\conda\envs\my-env\Lib\site-packages\arcgis\gis\_impl\_con\_connection.py, in post:
Line 720:   force_bytes=kwargs.pop('force_bytes', False))

File C:\pathto\Local\ESRI\conda\envs\my-env\Lib\site-packages\arcgis\gis\_impl\_con\_connection.py, in _handle_response:
Line 514:   self._handle_json_error(data['error'], errorcode)

File C:\pathto\Local\ESRI\conda\envs\my-env\Lib\site-packages\arcgis\gis\_impl\_con\_connection.py, in _handle_json_error:
Line 536:   raise Exception(errormessage)

Exception: Analyze Service error: Server tool execution failed : ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds. No csv or txt found in item. Failed to execute (Analyze Features for Portal). Failed. Failed to execute (Analyze Features for Portal). Failed.
(Error Code: 0)
---------------------------------------------------------------------------