<?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 using a variable for ID parsing in get method results in 400 error in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/using-a-variable-for-id-parsing-in-get-method/m-p/1337642#M9138</link>
    <description>&lt;P&gt;Hi I'm trying to get information from a whole list of items from my AGOL. To make that happen I made a txt file with all the ID's of the items that I want to approach. And for each item I want to get the information of the item. See code below.&lt;/P&gt;&lt;P&gt;urls= open("dir to file with urls")&lt;BR /&gt;for x in urls:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;print(x)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;item = gis.content.get(x)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;print(item)&lt;/P&gt;&lt;P&gt;Using the variable as shown above i get a 400 bad request error in return. However if I directly feed the ID in there like this: item = gis.content.get("458254021f2c47b2bb5ccaebd39323b2") I get the result I want.&lt;/P&gt;&lt;P&gt;Any idea on what could change if im trying to parse them from a variable instead of doing it by hand?&lt;/P&gt;</description>
    <pubDate>Fri, 13 Oct 2023 11:13:49 GMT</pubDate>
    <dc:creator>GuusvanderPutten</dc:creator>
    <dc:date>2023-10-13T11:13:49Z</dc:date>
    <item>
      <title>using a variable for ID parsing in get method results in 400 error</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/using-a-variable-for-id-parsing-in-get-method/m-p/1337642#M9138</link>
      <description>&lt;P&gt;Hi I'm trying to get information from a whole list of items from my AGOL. To make that happen I made a txt file with all the ID's of the items that I want to approach. And for each item I want to get the information of the item. See code below.&lt;/P&gt;&lt;P&gt;urls= open("dir to file with urls")&lt;BR /&gt;for x in urls:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;print(x)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;item = gis.content.get(x)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;print(item)&lt;/P&gt;&lt;P&gt;Using the variable as shown above i get a 400 bad request error in return. However if I directly feed the ID in there like this: item = gis.content.get("458254021f2c47b2bb5ccaebd39323b2") I get the result I want.&lt;/P&gt;&lt;P&gt;Any idea on what could change if im trying to parse them from a variable instead of doing it by hand?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2023 11:13:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/using-a-variable-for-id-parsing-in-get-method/m-p/1337642#M9138</guid>
      <dc:creator>GuusvanderPutten</dc:creator>
      <dc:date>2023-10-13T11:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: using a variable for ID parsing in get method results in 400 error</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/using-a-variable-for-id-parsing-in-get-method/m-p/1337673#M9140</link>
      <description>&lt;P&gt;It would help to know what x is - is that part printing okay? It would also help to know how the txt file is written. Line by line? Maybe there's some whitespace?&lt;BR /&gt;&lt;BR /&gt;I imagine you would want to being doing something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with open("/your/file") as f:
    lines = [line.strip() for line in f]
    for line in lines:
        item = gis.content.get(line)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2023 12:47:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/using-a-variable-for-id-parsing-in-get-method/m-p/1337673#M9140</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2023-10-13T12:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: using a variable for ID parsing in get method results in 400 error</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/using-a-variable-for-id-parsing-in-get-method/m-p/1338517#M9152</link>
      <description>&lt;P&gt;Thank you for your response, x returns the ID of the item im doing the .get() method on.&amp;nbsp;&lt;/P&gt;&lt;P&gt;the txt file is written in line for line, with no extra white between them.&lt;/P&gt;&lt;P&gt;"x" also returns the ID just as they are written in the file, even when i copy the ID from the log into the url directly it returns a normal value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im going to try the suggested code and will get back to you. Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 09:00:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/using-a-variable-for-id-parsing-in-get-method/m-p/1338517#M9152</guid>
      <dc:creator>GuusvanderPutten</dc:creator>
      <dc:date>2023-10-17T09:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: using a variable for ID parsing in get method results in 400 error</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/using-a-variable-for-id-parsing-in-get-method/m-p/1338525#M9154</link>
      <description>&lt;P&gt;Okay i have done a couple of more tests, for some reason the old code now returns the right values as well. I think after all it might have been a backend thing that i could not place. Thanks for thinking with me regardless.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 09:20:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/using-a-variable-for-id-parsing-in-get-method/m-p/1338525#M9154</guid>
      <dc:creator>GuusvanderPutten</dc:creator>
      <dc:date>2023-10-17T09:20:02Z</dc:date>
    </item>
  </channel>
</rss>

