Esri / ago-tools

A Python package to assist with administering ArcGIS Online Organizations.
Apache License 2.0
87 stars 88 forks source link

registerItems.py fails to add Type: WMS services #54

Open pnasuti-zz opened 7 years ago

pnasuti-zz commented 7 years ago

The script does not function for services of Type WMS to an ArcGIS Online or Portal for ArcGIS environment. This script executes perfectly for "Map Service" type, but not "WMS" type

CSV Line 1: title,url,tags,type,id,thumbnail,description,snippet,extent,spatialReference,accessInformation,licenseInfo,culture CSV Line 2: WMS_Service,https://sampleserver6.arcgisonline.com/arcgis/services/SampleWorldCities/MapServer/WMSServer?request=GetCapabilities&service=WMS,testtag,WMS,,,WMS,,,,,,

When executed directly, the script returns "0 items added". Watching network traffic, the script never executes the "addItem" call to the Portal sharing API.

ecaldwell commented 7 years ago

It could be failing due to the extra parameters on the WMS url. Try just https://sampleserver6.arcgisonline.com/arcgis/services/SampleWorldCities/MapServer/WMSServer for the url and see if it works.

pnasuti-zz commented 7 years ago

@ecaldwell

Thanks for the quick reply! Unfortunately the same response 0 items added for the URL added as "https://sampleserver6.arcgisonline.com/arcgis/services/SampleWorldCities/MapServer/WMSServer"

ecaldwell commented 7 years ago

Watching the network traffic for the workflow in the UI, it appears there's a call to a proxy service to populate some additional info. The additional info gets sent with the text parameter on the addItem call. There's a whole lot of info about the WMS in there.

You could try adding some logic to the registerItems method to populate the text parameter with the required info for a WMS.

{
    "title": "WMS",
    "url": "https://sampleserver6.arcgisonline.com/arcgis/services/SampleWorldCities/MapServer/WMSServer",
    "mapUrl": "https://sampleserver6.arcgisonline.com:443/arcgis/services/SampleWorldCities/MapServer/WmsServer",
    "version": "1.3.0",
    "layers": [{
        "name": "0",
        "title": "World",
        "legendURL": "https://sampleserver6.arcgisonline.com:443/arcgis/services/SampleWorldCities/MapServer/WmsServer?request=GetLegendGraphic%26version=1.3.0%26format=image/png%26layer=0",
        "queryable": true
    }, {
        "name": "1",
        "title": "Continent",
        "legendURL": "https://sampleserver6.arcgisonline.com:443/arcgis/services/SampleWorldCities/MapServer/WmsServer?request=GetLegendGraphic%26version=1.3.0%26format=image/png%26layer=1",
        "queryable": true
    }, {
        "name": "2",
        "title": "Cities",
        "legendURL": "https://sampleserver6.arcgisonline.com:443/arcgis/services/SampleWorldCities/MapServer/WmsServer?request=GetLegendGraphic%26version=1.3.0%26format=image/png%26layer=2",
        "queryable": true
    }],
    "copyright": "",
    "maxHeight": 4096,
    "maxWidth": 4096,
    "spatialReferences": [
        4326
    ],
    "format": null,
    "featureInfoUrl": "https://sampleserver6.arcgisonline.com:443/arcgis/services/SampleWorldCities/MapServer/WmsServer",
    "featureInfoFormat": "text/html"
}