Select to view content in your preferred language

Cannot Add WMS Layers with REST API

1093
0
08-21-2019 08:39 AM
CharlesNorsworthy
New Contributor

I am using ESRI’s REST API to create a new Web Map with WMS layers. I am trying to run the POST request http://{{domain}}/portal/sharing/rest/content/users/{{username}}/addItem with the following in the body:

f: json

title: testMap

type: Web Map

token: {{token}}

text:

{

  "operationalLayers": [

    {

      "id": "wms_3449",

      "url": "http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi",

      "visibility": true,

      "visibleLayers": [

        "nexrad-n0r"

      ],

      "opacity": 1,

      "title": "IEM WMS Service",

      "layerType": "WMS",

      "version": "1.3.0",

      "mapUrl": "http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi",

      "layers": [],

      "spatialReferences": [

        900913,

        4326,

        102100,

        3857

      ],

      "extent": [

        [

          -126,

          24

        ],

        [

          -66,

          50

        ]

      ],

      "maxWidth": 2048,

      "maxHeight": 2048

    }

  ],

  "baseMap": {

            "baseMapLayers": [

            {

            "id": "defaultBasemap",

            "layerType": "ArcGISTiledMapServiceLayer",

            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer",

            "visibility": true,

            "opacity": 1,

            "title": "ESRI_Imagery_World_2D"

            }

            ],

            "title": "ESRI_Imagery_World_2D"

            },

            "spatialReference": {

            "latestWkid": 4326

            }

Note, the WMS layer is based on the ArcGIS example using a WMS layer as an operational layer here: https://developers.arcgis.com/web-map-specification/objects/wmsLayer/ .  When I try to create this map, it initially says

{

    "success": true,

    "id": "<whatever the id is>",

    "folder": null

}

However, whenever I try to view the map using Map Viewer, I get an error message saying “The map cannot be drawn completely because one or more layers are not supported. These layers will be omitted.” From Map Viewer, when I go to Add->Add Layer from Web->A WMS OGC Web Service and put in the url from the text above, namely http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi?REQUEST=GetCapabilities&SERVICE=WMS, I get the following error: The WMS service, http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi, cannot be added to the map. It is either not available or you have entered an invalid URL for the type of layer you want to reference.

When I try to add this url manually, Fiddler says I got a 403 error when ArcGIS was trying to use a proxy for this request: GET /portal/sharing/proxy?https://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi?SERVICE=WMS&REQUEST=GetCapabilities HTTP/1.1

 

Does anyone know what is causing these errors? I appreciate any feedback.

0 Kudos
0 Replies