ArcGIS Server issue: I am not able to access Admin properties from a my secured (https) published service properties with python code, every time i am getting below SSLerror but not getting any SSL errors while doing admin page with browser.
" URLError: <urlopen error [Errno 1] _ssl.c:503: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol> "
Python Code is
import arcpy
import os
import httplib, urllib, urllib2, json
import getpass, shutil
import sys
def stopStartServices(server, port, adminUser, adminPass, stopStart, serviceList, token):
services = serviceList.split(';')
#modify the services(s)
for service in services:
service = urllib.quote(service.encode('utf8'))
op_service_url = "https://{}:{}/arcgis/admin/services/{}/{}?token={}&f=json".format(server, port, service, stopStart, token)
print(op_service_url)
status = urllib2.urlopen(op_service_url, ' ').read()
if 'success' in status:
print(str(service) + " === " + str(stopStart))
else:
print(status)
return
############################# Main #################################
arcpy.env.overwriteOutput = True
sqlFeatureClasspath = r"Database Connections\*********************************************"
oracleFeatureclassPath = r"Database Connections\*********************************************"
server = "*************************************"
port = "6443"
adminUser = "*****"
adminPass = "******"
serviceList = "WaterTapsLeadInspection/MLGWWaterTaps.MapServer"
token = "kLlQXyfenVdKFLSFzn06TNiATgEdBnrmm4yB_G3Y42gyRhwPoq-iEYSUtV1PAekR"
stopStartServices(server, port, adminUser, adminPass, "STOP", serviceList, token)
#arcpy.Delete_management(sqlFeatureClasspath)
arcpy.Copy_management(oracleFeatureclassPath, sqlFeatureClasspath)
stopStartServices(server, port, adminUser, adminPass, "START", serviceList, token)
Hi Radhika,
I receive errors when accessing URL's that implement HTTPS using python. To get around this, I use the SSLContext method from the SSL class. Try the following:
import arcpy
import os
import httplib, urllib, urllib2, json
import getpass, shutil
import sys, ssl
def stopStartServices(server, port, adminUser, adminPass, stopStart, serviceList, token):
services = serviceList.split(';')
#modify the services(s)
for service in services:
service = urllib.quote(service.encode('utf8'))
op_service_url = "https://{}:{}/arcgis/admin/services/{}/{}?token={}&f=json".format(server, port, service, stopStart, token)
print(op_service_url)
gcontext = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
status = urllib2.urlopen(op_service_url, context=gcontext).read()
if 'success' in status:
print(str(service) + " === " + str(stopStart))
else:
print(status)
return
Thank you very much for the reply. Let me try in this way.
Thanks
Radhika Dirisala
901-729-8981
>>>
Hi Jake,
I tired with your procedure that clears the SSL error, thank you for helping me but there is a small issue with POST method as mentioned below
{"status":"error","messages":["Only HTTP POST method is supported on this operation."]} Please let me know if you have any idea on this. Thanks you Radhika
You need to submit the parameters of the request, (the token and the response format), within the body of the request rather than within the URL itself. Take a look at this sample.
...
httpConn.request("POST", stopOrStartURL, params, headers)
...