The task - to get features in format json from ArcGIS Server (map service or geometry service)
I should use ArcGIS REST API with request and use large external file with parametres.
Its format json and its content - all the features where uniq1 in (1,2,3,4,5, ..., 100001)
"Uniq1": "1",
"Uniq1": "2", ...
I found an unclear syntax/example of version 9.3.
I have version 10.4 - I need some working example on online ArcGIS Server services like this one
https://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSFields/MapServer/0
Here is the help for 9.3 (question - if it is actual now, or API has changed for 10.4?)
6. Understand options for sending long JSON objects in a request (Getting Started with GeoServices REST API )
When using the REST API, you will normally use an HTML GET method in a form. When you use GET, the entire request is encoded in the URL. This is the preferred method to use whenever possible. However, in this mode, a URL is limited to as few as 1024 characters depending on the browser. Thus, if you have a long JSON object to include in the request, you will need to use POST.
A second option, when using certain Geometry Service and Geoprocessing Service operations, is to continue to use GET and to specify a URL to the input JSON object contained in a file on a public server.
Syntax: geometries = { "url": "<URL to file>"}
Example: geometries = { "url": "http: //myserver/mygeometries/afile.txt"}
http: // myserver / arcgis / rest / services / Geometry / GeometryServer / project? inSR = 4326 & outSR = 54004 & geometries = { "url": "http: //myserver/mygeometries/afile.txt"}
I have found that manual for 10.4 has not changed. So, please help with working example.
Here is a code example that will obtain the field information from the server link you mentioned. Since it does not require a password, I have omitted the password and token sections.
import urllib
import urllib2
import json
import sys
import collections
URL = "https://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSFields/MapServer/0"
query_dict = { "f": "json" }
jsonResponse = urllib.urlopen(URL, urllib.urlencode(query_dict))
jdata = json.loads(jsonResponse.read(),
object_pairs_hook=collections.OrderedDict)[u'fields']
print json.dumps(jdata, indent=4, sort_keys=True)
Is this the type of information you were looking for?
Thanks, Randy.
It did make sense.