I have a secured ArcGIS REST API which requires username and password to access it. I am able to access a public service and extract the data in the form of shapefile. Below is my code,
import urllib2
import arcpy
import os
myurl="http://services.thelist.tas.gov.au/arcgis/rest/services/Public"
myservice="/TopographyAndRelief/MapServer"
myparams="/8/query?where=objectid%3E50+and+objectid%3C2001&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=&returnGeometry=true&returnTrueCurves=false&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&resultOffset=&resultRecordCount=&f=pjson"
myRequest = myUrl + myService + myParams
myRequest = myurl + myservice + myparams
response = urllib2.urlopen(myRequest)
myJSON = response.read()
foo = open("C:\\Users\\venkatac\\Documents\\jsonOutput1.json", "wb")
foo.write(myJSON)
foo.close()
arcpy.JSONToFeatures_conversion("C:\\Users\\venkatac\\Documents\\jsonOutput1.json","C:\\Users\\venkatac\\Documents\\finalShapfile1.shp")
But I need to access a secured service using the credentials and extract the data.
Can anyone give me suggestions or any idea?