<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: file_type error when creating a KML item in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/file-type-error-when-creating-a-kml-item/m-p/741414#M285</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A class="link-titled" href="https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html?highlight=content%20add#arcgis.gis.ContentManager" title="https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html?highlight=content%20add#arcgis.gis.ContentManager"&gt;arcgis.gis module — arcgis 1.5.1 documentation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;filetype … have you tried leaving it off? the dictionary information isn't required and filetype isn't listed in the current help, whereas 'type' is&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 24 Nov 2018 14:02:16 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2018-11-24T14:02:16Z</dc:date>
    <item>
      <title>file_type error when creating a KML item</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/file-type-error-when-creating-a-kml-item/m-p/741413#M284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I'm trying to download a KML file and uploaded it to my ArcGIS Online account (code below). Although the scripts works well when running it shows the following error:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "C:/Users/aitor.calero/PycharmProjects/GISBox/Examples/DownloadAndPublish.py", line 35, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; feature_layer_item = item.publish()&lt;BR /&gt;&amp;nbsp; File "C:\Users\aitor.calero\PycharmProjects\GISBox\venv\lib\site-packages\arcgis\gis\__init__.py", line 5830, in publish&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise ValueError("A file_type must be provide, data format not recognized")&lt;BR /&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;ValueError: A file_type must be provide, data format not recognized&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;As you can see in my code I use 'file_type:kml' and I've tried also with '.kml' to no avail. Surpringsingly, the layer is published and worked. Any ideas of what I am doing wrong here?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CODE:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;from &lt;/SPAN&gt;arcgis.gis &lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;GIS
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;urllib.request

url = &lt;SPAN style="color: #008080; font-weight: bold;"&gt;&lt;SPAN&gt;r"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fdatos.madrid.es%2Fegob%2Fcatalogo%2F208223-7605484-trafico-intensidad-tramas.kml" target="_blank"&gt;https://datos.madrid.es/egob/catalogo/208223-7605484-trafico-intensidad-tramas.kml&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-weight: bold;"&gt;
&lt;/SPAN&gt;urllib.request.urlretrieve(url,&lt;SPAN style="color: #008080; font-weight: bold;"&gt;"C:&lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;\\&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-weight: bold;"&gt;Users&lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;\\&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-weight: bold;"&gt;aitor.calero&lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;\\&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-weight: bold;"&gt;Downloads&lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;\\&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-weight: bold;"&gt;trafico-intensidad.kml"&lt;/SPAN&gt;)

item_path = &lt;SPAN style="color: #008080; font-weight: bold;"&gt;r"C:\\Users\\aitor.calero\\Downloads\\trafico-intensidad.kml"
&lt;/SPAN&gt;item_properties={&lt;SPAN style="color: #008080; font-weight: bold;"&gt;'title'&lt;/SPAN&gt;:&lt;SPAN style="color: #008080; font-weight: bold;"&gt;'Intensidad de Tráfico'&lt;/SPAN&gt;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #008080; font-weight: bold;"&gt;'description'&lt;/SPAN&gt;:&lt;SPAN style="color: #008080; font-weight: bold;"&gt;'Intensidad de tráfico de Madrid actualizada cada 5 min'&lt;/SPAN&gt;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #008080; font-weight: bold;"&gt;'tags'&lt;/SPAN&gt;:&lt;SPAN style="color: #008080; font-weight: bold;"&gt;'tráfico, madrid, intensidad'&lt;/SPAN&gt;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #008080; font-weight: bold;"&gt;'type'&lt;/SPAN&gt;:&lt;SPAN style="color: #008080; font-weight: bold;"&gt;'KML'&lt;/SPAN&gt;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #008080; font-weight: bold;"&gt;'file_type'&lt;/SPAN&gt;:&lt;SPAN style="color: #008080; font-weight: bold;"&gt;'kml'&lt;/SPAN&gt;}

&lt;SPAN style="color: #808080; font-style: italic;"&gt;# we open a text file where my credentials are stored
&lt;/SPAN&gt;&lt;SPAN style="color: #808080; font-style: italic;"&gt;# this file must be in the same directory
&lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;with &lt;/SPAN&gt;&lt;SPAN style="color: #000080;"&gt;open&lt;/SPAN&gt;(&lt;SPAN style="color: #008080; font-weight: bold;"&gt;'../credentials.txt'&lt;/SPAN&gt;) &lt;SPAN style="color: #000080; font-weight: bold;"&gt;as &lt;/SPAN&gt;f:
&amp;nbsp;&amp;nbsp;&amp;nbsp; usr, p, arcgisboxdir = f.read().split(&lt;SPAN style="color: #008080; font-weight: bold;"&gt;'&lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;\n&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-weight: bold;"&gt;'&lt;/SPAN&gt;)&amp;nbsp; &lt;SPAN style="color: #808080; font-style: italic;"&gt;# or similar
&lt;/SPAN&gt;&lt;SPAN style="color: #808080; font-style: italic;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080; font-style: italic;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080; font-style: italic;"&gt;# we connect to my arcgis account using the previous credentials
&lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;def &lt;/SPAN&gt;connect_to_arcgis(_url, _usr, _pwd):
&amp;nbsp;&amp;nbsp;&amp;nbsp; gis = GIS(_url, _usr, _pwd)
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #000080;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #008080; font-weight: bold;"&gt;'Connected successfully to the [' &lt;/SPAN&gt;+ gis.properties.name + &lt;SPAN style="color: #008080; font-weight: bold;"&gt;'] organization&lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;\n&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-weight: bold;"&gt;'&lt;/SPAN&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #000080; font-weight: bold;"&gt;return &lt;/SPAN&gt;gis


gis = connect_to_arcgis(&lt;SPAN style="color: #008080; font-weight: bold;"&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fwww.arcgis.com" target="_blank"&gt;https://www.arcgis.com&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;, usr, p)

&lt;SPAN style="color: #808080; font-style: italic;"&gt;# search_item = gis.content.search('Intensidad de Tráfico')
&lt;/SPAN&gt;&lt;SPAN style="color: #808080; font-style: italic;"&gt;# item_for_deletion = gis.content.get(search_item[0].id)
&lt;/SPAN&gt;&lt;SPAN style="color: #808080; font-style: italic;"&gt;# item_for_deletion.delete()
&lt;/SPAN&gt;&lt;SPAN style="color: #808080; font-style: italic;"&gt;
&lt;/SPAN&gt;item = gis.content.add(&lt;SPAN style="color: #660099;"&gt;item_properties&lt;/SPAN&gt;=item_properties, &lt;SPAN style="color: #660099;"&gt;data&lt;/SPAN&gt;=item_path)
feature_layer_item = item.publish()

&lt;SPAN style="color: #000080;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #008080; font-weight: bold;"&gt;'The ['&lt;/SPAN&gt;+item[&lt;SPAN style="color: #008080; font-weight: bold;"&gt;'title'&lt;/SPAN&gt;] +&lt;SPAN style="color: #008080; font-weight: bold;"&gt;'] layer has been sucessfully published'&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:33:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/file-type-error-when-creating-a-kml-item/m-p/741413#M284</guid>
      <dc:creator>AitorCalero_García</dc:creator>
      <dc:date>2021-12-12T07:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: file_type error when creating a KML item</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/file-type-error-when-creating-a-kml-item/m-p/741414#M285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A class="link-titled" href="https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html?highlight=content%20add#arcgis.gis.ContentManager" title="https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html?highlight=content%20add#arcgis.gis.ContentManager"&gt;arcgis.gis module — arcgis 1.5.1 documentation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;filetype … have you tried leaving it off? the dictionary information isn't required and filetype isn't listed in the current help, whereas 'type' is&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 Nov 2018 14:02:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/file-type-error-when-creating-a-kml-item/m-p/741414#M285</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-11-24T14:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: file_type error when creating a KML item</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/file-type-error-when-creating-a-kml-item/m-p/741415#M286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I forget to mention that. Removing it does not work either. It just gives me the same error.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 Nov 2018 15:10:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/file-type-error-when-creating-a-kml-item/m-p/741415#M286</guid>
      <dc:creator>AitorCalero_García</dc:creator>
      <dc:date>2018-11-24T15:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: file_type error when creating a KML item</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/file-type-error-when-creating-a-kml-item/m-p/741416#M287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Problem solved! Since its a KML file, you do not need to "publish()" it. You just need to create the item:&lt;/P&gt;&lt;PRE style="background-color: #ffffff; color: #000000; font-family: 'Courier New'; font-size: 6,0pt;"&gt;item = gis.content.add(&lt;SPAN style="color: #660099;"&gt;item_properties&lt;/SPAN&gt;=item_properties, &lt;SPAN style="color: #660099;"&gt;data&lt;/SPAN&gt;=item_path)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 Nov 2018 19:21:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/file-type-error-when-creating-a-kml-item/m-p/741416#M287</guid>
      <dc:creator>AitorCalero_García</dc:creator>
      <dc:date>2018-11-24T19:21:17Z</dc:date>
    </item>
  </channel>
</rss>

