<?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: Error when querying REST API in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/error-when-querying-rest-api/m-p/1024134#M59826</link>
    <description>&lt;P data-unlink="true"&gt;In this case, the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/classes/featureset.htm" target="_self"&gt;FeatureSet - ArcGIS Pro | Documentation&lt;/A&gt; gives an example, FeatureSet example 2.&amp;nbsp; The query needs to be passed as a separate argument and not part of the URL.&lt;/P&gt;</description>
    <pubDate>Sat, 06 Feb 2021 15:59:37 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2021-02-06T15:59:37Z</dc:date>
    <item>
      <title>Error when querying REST API</title>
      <link>https://community.esri.com/t5/python-questions/error-when-querying-rest-api/m-p/1023918#M59821</link>
      <description>&lt;P&gt;I am pretty new to working with the REST API and I'm trying to query a feature service on our organization's server using arcpy. Here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;fs_url = r"https://maps.waterlandlife.org/arcgis/rest/services/PNHP/NHAEdit/FeatureServer/1/query?where=STATUS='C'&amp;amp;outFields=*&amp;amp;returnGeometry=true&amp;amp;f=JSON" 
fs = arcpy.FeatureSet()
fs.load(fs_url)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried to change the options for nearly all of the parameters here and tried including other parameters or excluding some of these. I keep getting the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;RuntimeError: RecordSetObject: Cannot open table for Load&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm able to load the feature set fine without the query and have looked at a ton of resources online and can't find any solutions that have worked. Can anyone help me out with what I'm doing wrong? Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 16:08:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-when-querying-rest-api/m-p/1023918#M59821</guid>
      <dc:creator>MollyMoore</dc:creator>
      <dc:date>2021-02-05T16:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: Error when querying REST API</title>
      <link>https://community.esri.com/t5/python-questions/error-when-querying-rest-api/m-p/1023937#M59822</link>
      <description>&lt;P&gt;have you supplied a token with the url? &amp;amp;token=&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 16:58:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-when-querying-rest-api/m-p/1023937#M59822</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-02-05T16:58:09Z</dc:date>
    </item>
    <item>
      <title>Re: Error when querying REST API</title>
      <link>https://community.esri.com/t5/python-questions/error-when-querying-rest-api/m-p/1023943#M59823</link>
      <description>&lt;P&gt;I have not. I figured since it was letting me use the feature service layer without the query that this wasn't the issue. But, I'll try this now.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 17:16:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-when-querying-rest-api/m-p/1023943#M59823</guid>
      <dc:creator>MollyMoore</dc:creator>
      <dc:date>2021-02-05T17:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: Error when querying REST API</title>
      <link>https://community.esri.com/t5/python-questions/error-when-querying-rest-api/m-p/1023976#M59824</link>
      <description>&lt;P&gt;Are you using Pro or ArcGIS Desktop/ArcMap?&amp;nbsp; If you are using ArcMap, what you are trying won't work.&amp;nbsp; If you are using Pro, you need to break your query out separate from the URL to the hosted feature layer.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 18:30:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-when-querying-rest-api/m-p/1023976#M59824</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-02-05T18:30:41Z</dc:date>
    </item>
    <item>
      <title>Re: Error when querying REST API</title>
      <link>https://community.esri.com/t5/python-questions/error-when-querying-rest-api/m-p/1024037#M59825</link>
      <description>&lt;P&gt;Yes, this is being used in a toolbox that I'm running through Pro. Do you mean that I need to bring in the data and then query it in another step? Or is there a way to separate the query from the URL in the feature service request? If the latter, is there an example of this somewhere? I couldn't find anything like this.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 20:39:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-when-querying-rest-api/m-p/1024037#M59825</guid>
      <dc:creator>MollyMoore</dc:creator>
      <dc:date>2021-02-05T20:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: Error when querying REST API</title>
      <link>https://community.esri.com/t5/python-questions/error-when-querying-rest-api/m-p/1024134#M59826</link>
      <description>&lt;P data-unlink="true"&gt;In this case, the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/classes/featureset.htm" target="_self"&gt;FeatureSet - ArcGIS Pro | Documentation&lt;/A&gt; gives an example, FeatureSet example 2.&amp;nbsp; The query needs to be passed as a separate argument and not part of the URL.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Feb 2021 15:59:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-when-querying-rest-api/m-p/1024134#M59826</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-02-06T15:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: Error when querying REST API</title>
      <link>https://community.esri.com/t5/python-questions/error-when-querying-rest-api/m-p/1024417#M59837</link>
      <description>&lt;P&gt;Thank you! This works for the given example. However, I'm unable to pass a list query. I can pass the list query without error, but it ignores it and loads all features into the feature set. This is what I'm passing:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;nha_expression = "NHA_JOIN_ID IN ({0})".format(','.join(nha_ids))
nha_core_fs = arcpy.FeatureSet()
nha_core_fs.load(nha_core_url,nha_expression)&lt;/LI-CODE&gt;&lt;P&gt;The nha_expression looks like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;'NHA_JOIN_ID IN (xxx42966,xxx42967,xxx43009)'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am able to drop the necessary records after I load in the features with an update cursor, but I figured it would be a lot more elegant and faster to just not load them in the first place through the where clause, so if anyone has ideas about why it's not honoring the query, I'd appreciate it!&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 16:13:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-when-querying-rest-api/m-p/1024417#M59837</guid>
      <dc:creator>MollyMoore</dc:creator>
      <dc:date>2021-02-08T16:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: Error when querying REST API</title>
      <link>https://community.esri.com/t5/python-questions/error-when-querying-rest-api/m-p/1024423#M59838</link>
      <description>&lt;P&gt;I think the list items need to be in quotes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;nha_expression = "NHA_JOIN_ID IN ('{}')".format("','".join(f for f in nha_ids))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;to make it&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;"NHA_JOIN_ID IN ('xxx42966','xxx42967','xxx43009')"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 17:58:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-when-querying-rest-api/m-p/1024423#M59838</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-02-08T17:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: Error when querying REST API</title>
      <link>https://community.esri.com/t5/python-questions/error-when-querying-rest-api/m-p/1024479#M59843</link>
      <description>&lt;P&gt;Swap the double and single quotes: &amp;nbsp; &lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/mapping/navigation/sql-reference-for-elements-used-in-query-expressions.htm" target="_blank"&gt;SQL reference for query expressions used in ArcGIS—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;Strings must always be enclosed in single quotation marks in queries, for example: STATE_NAME = 'California'&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 08 Feb 2021 17:48:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-when-querying-rest-api/m-p/1024479#M59843</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-02-08T17:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: Error when querying REST API</title>
      <link>https://community.esri.com/t5/python-questions/error-when-querying-rest-api/m-p/1024481#M59844</link>
      <description>&lt;P&gt;This did the trick (with the single quotes). Thank you all!&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 17:49:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-when-querying-rest-api/m-p/1024481#M59844</guid>
      <dc:creator>MollyMoore</dc:creator>
      <dc:date>2021-02-08T17:49:46Z</dc:date>
    </item>
  </channel>
</rss>

