1

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?

  • 1
    Have you done any research into using tokens? – Vince Jun 18 '17 at 12:32
  • Actually I have not tried...could you give me some help on it? – Shenbaga Rajan Jun 18 '17 at 14:13
  • Is there any help or documentation on how to access the secured services using Python or Arcpy? – Shenbaga Rajan Jun 19 '17 at 8:46
  • As the documentation found by googling indicates, it depends on how the website is secured. Have you tried to request a token? What was the result? Note that you should be using HTTPS when passing a password, and realy ought to be using POST for large/complex parameter lists. GIS SE works best when you provide a specific problem. Asking for documentation gives the impression that you're unwilling to follow up on leads and help yourself. This will not encourage others to help you. – Vince Jun 19 '17 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.