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?
import arcpy
from arcpy import env
import requests
import json
from json import loads, dumps
env.outputCoordinateSystem = arcpy.SpatialReference(4326)
#Buffer
Point = arcpy.GetParameterAsText(0)
Buffer ="in_memory/Buffer"
Dist = 100
Distance = str(Dist) + " Meters"
outBuffer = arcpy.Buffer_analysis(Point, Buffer, Distance)
arcpy.SetParameter(1, outBuffer)
for row in arcpy.da.SearchCursor(outBuffer, ["SHAPE@"]):
extent = row[0].extent
XMin = str(extent.XMin)
YMin = str(extent.YMin)
XMax = str(extent.XMax)
YMax = str(extent.YMax)
coordinates = XMin + "," + YMin + "," + XMax + "," + YMax
arcpy.AddMessage(coordinates)
resp = requests.post("https://xyzxyzxy.com/arcgis/sharing/rest/generateToken?f=json",
data={"username":"xyzxy", "password":"xyzxy",
"referer":"https://xyzxyzxy.com"})
tokenCode = str(json.dumps(resp.json()["token"]))
arcpy.AddMessage(tokenCode)
mapService = "https://xyzxyzxy.com/arcgis/services/MapServices/NameofLayer/MapServer/WCSServer?SERVICE=WCS&VERSION..." + coordinates + "&FORMAT=GTiff" + "?f=json&token=" + tokenCode
arcpy.AddMessage(mapService)
arcpy.SetParameter(2, mapService)
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.