<?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: Python script to replicate an ArcGIS Online hosted feature service. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-script-to-replicate-an-arcgis-online-hosted/m-p/741737#M57340</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think my token is valid, when I run the same code in IDLE interactively I print out the token and it gives a long string with an expiration if I remember correctly.&amp;nbsp; I also get a very large dictionary in my crJson variable, but 'URL' is not among the keys.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 25 Mar 2016 19:27:38 GMT</pubDate>
    <dc:creator>JeffWard</dc:creator>
    <dc:date>2016-03-25T19:27:38Z</dc:date>
    <item>
      <title>Python script to replicate an ArcGIS Online hosted feature service.</title>
      <link>https://community.esri.com/t5/python-questions/python-script-to-replicate-an-arcgis-online-hosted/m-p/741732#M57335</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to replicate a hosted feature service in a local file geodatabase to do some local analysis.&amp;nbsp; I have found &lt;A href="https://gist.github.com/oevans/6992139" rel="nofollow noopener noreferrer" target="_blank"&gt;this code&lt;/A&gt; on GitHub that I have been trying to use.&amp;nbsp; I set it up according to the instructions and I get a KeyError on line 9 below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;crValues = {'f' : 'json',
&amp;nbsp; 'layers' : '0',
&amp;nbsp; 'returnAttachments' : 'true',
&amp;nbsp; 'token' : token }
crData = urllib.urlencode(crValues)
crRequest = urllib2.Request(crUrl, crData)
crResponse = urllib2.urlopen(crRequest)
crJson = json.load(crResponse)
replicaUrl = crJson['URL']
urllib.urlretrieve(replicaUrl, 'myLayer.json')&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Error screenshot:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/193008_pastedImage_1.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;I was able to run all of the commands in the IDLE interactive window successfully and check the results of each command.&amp;nbsp; There is no 'URL' key in the crJson dictionary.&amp;nbsp; Here are a list of the keys that are:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;[u'supportsCalculate', u'editingInfo', u'typeIdField', u'supportsValidateSql', u'advancedQueryCapabilities', u'supportsCoordinatesQuantization', u'supportsRollbackOnFailureParameter', u'allowGeometryUpdates', u'globalIdField', u'supportsAdvancedQueries', u'id', u'relationships', u'drawingInfo', u'capabilities', u'indexes', u'currentVersion', u'geometryType', u'hasStaticData', u'type', u'useStandardizedQueries', u'supportedQueryFormats', u'isDataVersioned', u'supportsAttachmentsByUploadId', u'supportsApplyEditsWithGlobalIds', u'description', u'standardMaxRecordCount', u'defaultVisibility', u'extent', u'objectIdField', u'tileMaxRecordCount', u'htmlPopupType', u'types', u'hasM', u'displayField', u'name', u'templates', u'supportsStatistics', u'hasAttachments', u'fields', u'maxScale', u'copyrightText', u'hasZ', u'maxRecordCount', u'minScale', u'maxRecordCountFactor', u'editFieldsInfo', u'serviceItemId']&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;The code is over two years old, have there been changes to the way requests are handled?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any thoughts?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:34:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-to-replicate-an-arcgis-online-hosted/m-p/741732#M57335</guid>
      <dc:creator>JeffWard</dc:creator>
      <dc:date>2021-12-12T07:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to replicate an ArcGIS Online hosted feature service.</title>
      <link>https://community.esri.com/t5/python-questions/python-script-to-replicate-an-arcgis-online-hosted/m-p/741733#M57336</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jeff:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First what request are you making ie. what's the value of crUrl? &lt;/P&gt;&lt;P&gt;Second, i do think that methodology is a little outdated.... Do any of the solutions in this blog post help?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://blogs.esri.com/esri/arcgis/2013/10/10/quick-tips-consuming-feature-services-with-geoprocessing/" title="https://blogs.esri.com/esri/arcgis/2013/10/10/quick-tips-consuming-feature-services-with-geoprocessing/"&gt;Quick Tips: Consuming Feature Services with Geoprocessing | ArcGIS Blog&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you really care about creating a "replica" which keeps everything in sync for reloading offline editing or do you just need a copy?&amp;nbsp; The export item is the best way to download a copy: &lt;A href="http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Export_Item/02r30000008s000000/" title="http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Export_Item/02r30000008s000000/"&gt;ArcGIS REST API&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Mar 2016 17:18:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-to-replicate-an-arcgis-online-hosted/m-p/741733#M57336</guid>
      <dc:creator>FredSpataro</dc:creator>
      <dc:date>2016-03-24T17:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to replicate an ArcGIS Online hosted feature service.</title>
      <link>https://community.esri.com/t5/python-questions/python-script-to-replicate-an-arcgis-online-hosted/m-p/741734#M57337</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I haven't had time to look at the GitHub page yet, but the error message is indicating the crJson dictionary does not have an entry for 'URL'.&amp;nbsp; I would look at the raw/returned JSON.&amp;nbsp; The code wants a key labeled 'URL', and it appears one isn't getting returned from your crRequest.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Mar 2016 17:20:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-to-replicate-an-arcgis-online-hosted/m-p/741734#M57337</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-03-24T17:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to replicate an ArcGIS Online hosted feature service.</title>
      <link>https://community.esri.com/t5/python-questions/python-script-to-replicate-an-arcgis-online-hosted/m-p/741735#M57338</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jeff,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check your token, if you aren't getting a URL string returned in your JSON object then chances are the token wasn't valid and your JSON object isn't getting built. I'm running the same code but am finding that during urlretreive method, I'm not getting JSON written to the file I'm specifying. Instead the file contains HTML that holds a div block showing restErrors with a value "Token Required".&amp;nbsp; This code was working a few weeks ago but now seems to break due to no token authentication. Maybe others are experiencing the same behavior.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Andy &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Mar 2016 14:25:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-to-replicate-an-arcgis-online-hosted/m-p/741735#M57338</guid>
      <dc:creator>AndyOmmen</dc:creator>
      <dc:date>2016-03-25T14:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to replicate an ArcGIS Online hosted feature service.</title>
      <link>https://community.esri.com/t5/python-questions/python-script-to-replicate-an-arcgis-online-hosted/m-p/741736#M57339</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I listed the keys in the crJson dictionary in my original post and 'URL' wasn't among them.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Mar 2016 19:23:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-to-replicate-an-arcgis-online-hosted/m-p/741736#M57339</guid>
      <dc:creator>JeffWard</dc:creator>
      <dc:date>2016-03-25T19:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to replicate an ArcGIS Online hosted feature service.</title>
      <link>https://community.esri.com/t5/python-questions/python-script-to-replicate-an-arcgis-online-hosted/m-p/741737#M57340</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think my token is valid, when I run the same code in IDLE interactively I print out the token and it gives a long string with an expiration if I remember correctly.&amp;nbsp; I also get a very large dictionary in my crJson variable, but 'URL' is not among the keys.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Mar 2016 19:27:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-to-replicate-an-arcgis-online-hosted/m-p/741737#M57340</guid>
      <dc:creator>JeffWard</dc:creator>
      <dc:date>2016-03-25T19:27:38Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to replicate an ArcGIS Online hosted feature service.</title>
      <link>https://community.esri.com/t5/python-questions/python-script-to-replicate-an-arcgis-online-hosted/m-p/741738#M57341</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jeff,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think it might be the url you're sending... you might be missing the "CreateReplica" portion on the end.&amp;nbsp; If I make a request without the CreateReplica I get back the overall FeatureService description JSON which has keys that match the output you listed.&amp;nbsp; So the value of crURL should be in the format:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="unlinked" title="http://services1.arcgis.com/qkYTKlfKEB2WYL01/arcgis/rest/services/Cruise_MSO_2099_DeborgiaDeerActual/FeatureServer/CreateReplica"&gt;http://services1.arcgis.com/{id}/arcgis/rest/services/{name}/FeatureServer/&lt;STRONG&gt;CreateReplica&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Fred&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Mar 2016 19:50:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-to-replicate-an-arcgis-online-hosted/m-p/741738#M57341</guid>
      <dc:creator>FredSpataro</dc:creator>
      <dc:date>2016-03-25T19:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to replicate an ArcGIS Online hosted feature service.</title>
      <link>https://community.esri.com/t5/python-questions/python-script-to-replicate-an-arcgis-online-hosted/m-p/741739#M57342</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Fred, I think you are right.&amp;nbsp; I just copied my url from my layer and didn't see I needed the CreateReplica.&amp;nbsp; I will have to look into this on Monday.&amp;nbsp; Thanks so much for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Mar 2016 21:59:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-to-replicate-an-arcgis-online-hosted/m-p/741739#M57342</guid>
      <dc:creator>JeffWard</dc:creator>
      <dc:date>2016-03-25T21:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to replicate an ArcGIS Online hosted feature service.</title>
      <link>https://community.esri.com/t5/python-questions/python-script-to-replicate-an-arcgis-online-hosted/m-p/741740#M57343</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You were right Fred.&amp;nbsp; I had failed to include the createReplica method at the end of my url.&amp;nbsp; I am now able to get the URL key from the json response.&amp;nbsp; But now I am running into another error that I will post in another question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Mar 2016 20:41:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-to-replicate-an-arcgis-online-hosted/m-p/741740#M57343</guid>
      <dc:creator>JeffWard</dc:creator>
      <dc:date>2016-03-28T20:41:01Z</dc:date>
    </item>
  </channel>
</rss>

