<?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 How to update a csv item in ArcGIS Online without using arcgis methods? (REST API) in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-update-a-csv-item-in-arcgis-online-without/m-p/1070704#M61426</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I need to update a csv item in an ArcGIS Online Organization. For some reasones I need to do it without using arcgis python module.&lt;/P&gt;&lt;P&gt;The idea is basically to generate a token and update the item by using the python requests library (or urllib). Somehow I cannot make it work with the requests lib.&lt;/P&gt;&lt;P&gt;Help is appreciated!&lt;BR /&gt;Thanks in advance folks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;token = arcpy.GetSigninToken()

url="https://myorganization.arcgis.com/sharing/rest/content/users/username/9d0a35bf33c24f289e626b51f9asdf4578/items/123456782345678itemId/update"

payload={
    'description': 'Rest Test',
    'overwrite': 'true',
    'async': 'true',
    'token': token['token'],
    'title': 'RestTestFile',
    'name': 'RestTestFile.csv',
    'type': 'CSV',
    'tags': 'RestTest',
    'typeKeywords': 'CSV'}
    files={
        'file': ('RestTestFile.csv', open(file_path_variable,'rb'), 'text/csv')
    }

# two kinds of requests with requests library
response = requests.request("POST", url, data=payload, files=files)
r = requests.post(url, data=payload, files=files)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Jun 2021 20:44:42 GMT</pubDate>
    <dc:creator>ChristianBischof</dc:creator>
    <dc:date>2021-06-21T20:44:42Z</dc:date>
    <item>
      <title>How to update a csv item in ArcGIS Online without using arcgis methods? (REST API)</title>
      <link>https://community.esri.com/t5/python-questions/how-to-update-a-csv-item-in-arcgis-online-without/m-p/1070704#M61426</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I need to update a csv item in an ArcGIS Online Organization. For some reasones I need to do it without using arcgis python module.&lt;/P&gt;&lt;P&gt;The idea is basically to generate a token and update the item by using the python requests library (or urllib). Somehow I cannot make it work with the requests lib.&lt;/P&gt;&lt;P&gt;Help is appreciated!&lt;BR /&gt;Thanks in advance folks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;token = arcpy.GetSigninToken()

url="https://myorganization.arcgis.com/sharing/rest/content/users/username/9d0a35bf33c24f289e626b51f9asdf4578/items/123456782345678itemId/update"

payload={
    'description': 'Rest Test',
    'overwrite': 'true',
    'async': 'true',
    'token': token['token'],
    'title': 'RestTestFile',
    'name': 'RestTestFile.csv',
    'type': 'CSV',
    'tags': 'RestTest',
    'typeKeywords': 'CSV'}
    files={
        'file': ('RestTestFile.csv', open(file_path_variable,'rb'), 'text/csv')
    }

# two kinds of requests with requests library
response = requests.request("POST", url, data=payload, files=files)
r = requests.post(url, data=payload, files=files)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 20:44:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-update-a-csv-item-in-arcgis-online-without/m-p/1070704#M61426</guid>
      <dc:creator>ChristianBischof</dc:creator>
      <dc:date>2021-06-21T20:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to update a csv item in ArcGIS Online without using arcgis methods? (REST API)</title>
      <link>https://community.esri.com/t5/python-questions/how-to-update-a-csv-item-in-arcgis-online-without/m-p/1070709#M61427</link>
      <description>&lt;P&gt;Stupid me got it, just forgot the 'f' parameter -&amp;gt; set to JSON in this sample. Anyway wanted to provide you my solution.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;token = arcpy.GetSigninToken()

url="https://myorganization.arcgis.com/sharing/rest/content/users/username/9d0a35bf33c24f289e626b51f9asdf4578/items/123456782345678itemId/update"

payload={
    # THIS PARAMETER MADE THE DIFFERENCE
    'f': 'json',
    'description': 'Rest Test',
    'overwrite': 'true',
    'async': 'true',
    'token': token['token'],
    'title': 'RestTestFile',
    'name': 'RestTestFile.csv',
    'type': 'CSV',
    'tags': 'RestTest',
    'typeKeywords': 'CSV'}
    files={
        'file': ('RestTestFile.csv', open(file_path_variable,'rb'), 'text/csv')
    }

# two kinds of requests with requests library
response = requests.request("POST", url, data=payload, files=files)
r = requests.post(url, data=payload, files=files)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 21 Jun 2021 20:55:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-update-a-csv-item-in-arcgis-online-without/m-p/1070709#M61427</guid>
      <dc:creator>ChristianBischof</dc:creator>
      <dc:date>2021-06-21T20:55:29Z</dc:date>
    </item>
  </channel>
</rss>

