I am trying to create a geoprocessing service that let you created a buffer and use that buffer to clip a WMS service I published on my Portal.
The WMS service is protected and I managed to get to the service using a token but I cannot find a way to download the data.
This is my code, what am I doing wrong?
from arcpy import env
from json import loads, dumps
env.outputCoordinateSystem = arcpy.SpatialReference(4326)
Point = arcpy.GetParameterAsText(0)
Dist = 100
Distance = str(Dist) + " Meters"
outBuffer = arcpy.Buffer_analysis(Point, Buffer, Distance)
for row in arcpy.da.SearchCursor(outBuffer, ["SHAPE@"]):
extent = row.extent
XMin = str(extent.XMin)
YMin = str(extent.YMin)
XMax = str(extent.XMax)
YMax = str(extent.YMax)
coordinates = XMin + "," + YMin + "," + XMax + "," + YMax
resp = requests.post("https://xxxxxxxx.com/arcgis/sharing/rest/generateToken?f=json",
tokenCode = str(json.dumps(resp.json()["token"]))
mapService = "https://xxxxxxxx.com/arcgis/services/MapServices/NameofLayer/MapServer/WCSServer?SERVICE=WCS&VERSION..." + coordinates + "&FORMAT=GTiff" + "?f=json&token=" + tokenCode
I think I have problems building the request. After looking at the results I received back from the server I changed the request to:
However I get the error message that " parameter COVERAGE is invalid" even if passed the name of the layer.