<?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: Access a value in the JSON response from CreateReplica() in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/access-a-value-in-the-json-response-from/m-p/1335890#M9121</link>
    <description>&lt;P&gt;Thank you very much! I hadn't set up a post request, which is the missing piece.&lt;/P&gt;</description>
    <pubDate>Fri, 06 Oct 2023 18:25:55 GMT</pubDate>
    <dc:creator>DanielCardenas_G2</dc:creator>
    <dc:date>2023-10-06T18:25:55Z</dc:date>
    <item>
      <title>Access a value in the JSON response from CreateReplica()</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/access-a-value-in-the-json-response-from/m-p/1335646#M9114</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;I'm hoping someone can help me to access a value in a JSON response that results from a successful CreateReplica() call. I'm following the documentation here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/rest/services-reference/enterprise/create-replica.htm" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/rest/services-reference/enterprise/create-replica.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;In the examples below, a call to CreateReplica() with all the correct parameters in place would return the first example dictionary.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The statusURL value in the first dictionary links to a web page containing the data in the second dictionary, presented in HTML. What I'm trying to do is access the "status" value in the second dictionary using the API for Python. The closest I've gotten to it so far is by viewing the response.text result from a GET request on the statusUrl, but that's the full HTML contents of the web page. I could scrape that, but I'd rather not. Surely there's a better way?&lt;/P&gt;&lt;P&gt;From the docs:&lt;/P&gt;&lt;P&gt;JSON Response example&lt;BR /&gt;Example one&lt;BR /&gt;When async is set to true, the request is processed as an asynchronous job and a URL that a client can visit to check the status of the job is returned. The file returned in the resultURL is a sqlite geodatabase. The sqlite replica geodatabase contains the same information and data as the JSON file content in the subsequent example:&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"statusUrl": "&lt;A href="https://services.myserver.com/arcgis/rest/services/LandUse/FeatureServer/jobs/j0b4b6064db0f44e6b5f39c4ef301d1f9" target="_blank"&gt;https://services.myserver.com/arcgis/rest/services/LandUse/FeatureServer/jobs/j0b4b6064db0f44e6b5f39c4ef301d1f9&lt;/A&gt;"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Response example for the status resource:&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"transportType":"esriTransportTypeUrl",&lt;BR /&gt;"responseType": "esriReplicaResponseTypeData",&lt;BR /&gt;"replicaName": "Meters",&lt;BR /&gt;"resultUrl": "&lt;A href="https://arcgis.com/lidGgNLxw9LL0SbI/ArcGIS/rest/services/SaveTheBay/replicafiles/c2f366ffbf5549a48727d2529b2c6ed5.json" target="_blank"&gt;https://arcgis.com/lidGgNLxw9LL0SbI/ArcGIS/rest/services/SaveTheBay/replicafiles/c2f366ffbf5549a48727d2529b2c6ed5.json&lt;/A&gt;",&lt;BR /&gt;"submissionTime": 1379366479000,&lt;BR /&gt;"lastUpdatedTime": 1379366482000,&lt;BR /&gt;"status": "Completed"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 00:26:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/access-a-value-in-the-json-response-from/m-p/1335646#M9114</guid>
      <dc:creator>DanielCardenas_G2</dc:creator>
      <dc:date>2023-10-06T00:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: Access a value in the JSON response from CreateReplica()</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/access-a-value-in-the-json-response-from/m-p/1335740#M9117</link>
      <description>&lt;P&gt;Is this what you're trying to do?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import requests
from arcgis import GIS
from arcgis.features import FeatureLayerCollection

url = "https://pythonapi.playground.esri.com/server/rest/services/Hosted/Ports_in_the_Western_US/FeatureServer"
gis = GIS("https://pythonapi.playground.esri.com/portal", "arcgis_python", "amazing_arcgis_123")
flc = FeatureLayerCollection(url, gis)

replica = flc.replicas.create(
    replica_name = 'arcgis_python_api_ports',                          
    layers='0',                              
    sync_model="perLayer",
    target_type="server",
    data_format="sqlite",
    asynchronous=True
)
status_url = replica["statusUrl"]

params = {
    "f": "json", 
    "token": gis._con.token
}
r = requests.post(status_url, params=params)
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where you can then use r.json() to get a json response from the status url:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;{'responseType': 'esriReplicaResponseTypeData',
 'replicaID': '037B207A-4E7B-423C-AC99-F9EE3AAE96E6',
 'replicaName': 'arcgis_python_1696596866617',
 'resultUrl': 'https://pythonapi.playground.esri.com/server/rest/directories/arcgisjobs/system/synctools_gpserver/je1fb0eacd85444baae62274cd6ea9811/scratch/_ags_data5464957EDC9346558F5FFEA3DCE5AEBC.geodatabase',
 'transportType': 'esriTransportTypeURL',
 'targetType': 'server',
 'lastUpdatedTime': 1696596867000,
 'layerServerGens': [{'serverGen': 1696596865593, 'id': 0, 'serverSibGen': 0}],
 'submissionTime': 1696596865000,
 'status': 'Completed'}&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 06 Oct 2023 12:59:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/access-a-value-in-the-json-response-from/m-p/1335740#M9117</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2023-10-06T12:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Access a value in the JSON response from CreateReplica()</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/access-a-value-in-the-json-response-from/m-p/1335890#M9121</link>
      <description>&lt;P&gt;Thank you very much! I hadn't set up a post request, which is the missing piece.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 18:25:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/access-a-value-in-the-json-response-from/m-p/1335890#M9121</guid>
      <dc:creator>DanielCardenas_G2</dc:creator>
      <dc:date>2023-10-06T18:25:55Z</dc:date>
    </item>
  </channel>
</rss>

