Select to view content in your preferred language

Why can't I save a JSON locally with the arcgis python api

06-02-2017 02:03 AM
New Contributor II

Really strange behaviour. When I create a replica of a file and set as data-format 'filegdb':

replica1 = flc.replicas.create(replica_name = "test", layers='0', data_format='filegdb', out_path='/Users/username/Desktop')

I get:


and file appears on Desktop.
However, when I change data_format to 'json' or when I delete the line (since JSON is default) the result is:

{'transportType': 'esriTransportTypeUrl', 'URL': ''}

And no file appears on Desktop. What can go wrong here? I use the default and follow: Checking out data from feature layers using replicas | ArcGIS for Developers 

Extract and Sync are on, I check that beforehand.

0 Kudos
2 Replies
MVP Esteemed Contributor

What you are seeing is expected behavior.  In the documentation you reference, there is a link to Create Replica for the ArcGIS REST API.  Since the ArcGIS API for Python is really driven by the ArcGIS REST API, it is important to understand the REST API equivalent of Python API functions.  In this case, the ArcGIS REST API only supports json and sqlite data formats while the Python API supports more, so the Python API is doing something with the results from json to create file geodatabase or shape files.  You are getting the URL of the JSON results returned to you, you just need to download it to a file if you want to store it in a file.

0 Kudos
New Contributor II

You do know that the sqlite is exporting to the out_path. 

So REST API: json | sqlite

Python API: json | sqlite | filegdb | shapefile

And in the python API the possibility to select an out_path. 

Result: Only json doesn't export to the mentioned out_path while the other's do. 

So, don't you agree that it seems is off? Or are you able to get the json on out_path location?

0 Kudos