[GIS] An unexpected error occurred processing the request when requesting the layer definition Url

arcgis-10.0arcgis-rest-apiarcgis-server

When I publish my MXD in ArcGIS 10.0, the service url which returns the layer definitions in json format returns an error.

{"currentVersion":10.05,"error":{"code":500, 
"message":"An unexpected error occurred processing the request.","details":[]}}],"tables":[]}

The url looks something like this:

http://myserver/arcgis/rest/services/myservice/MapServer/layers?f=json

The MXD contains 150-200 layers. If I remove a few of the layers near the bottom, it renders correctly. These layers at the bottom work fine in other MXDs. If I remove the bottom layers to get it working, but try adding completely different layers, it fails.

I found the errors being logged in a file called restlog.txt. So it looks like a bug in the code that renders the layer definitions.

ERROR:Index was outside the bounds of the array.
   at ESRI.ArcGIS.REST.MapServer.MapLayerRequestHandler.get_LayerDefinitionExpression()
   at ESRI.ArcGIS.REST.MapServer.MapLayerJsonFormatter.WriteJsonResponse()
   at ESRI.ArcGIS.REST.JsonFormatter.WriteResponse()

Here is a public Url (not related to me) illustrating the error:
http://epamap5.epa.gov/ArcGIS/rest/services/EMEF/TRINAT_2012/MapServer/layers?f=json

Is there a documented or known bug in the 10.0 Arcgis server code that renders the layer definitions.

Any idea how to get around this error and stay on 10.0?

Best Answer

There is a documented bug for this issue: NIM-063468. According to the bug report,

Synopsis: If one or more layers in a map that is published has a broken link, .NET REST returns an "Index was outside the bounds of the array." exception

Solution: Update the map document to fix the broken layer(s).

I was using ArcMap 10.2.2 to open and save the MXD file as a 10.0 document. The MDX had no issues when opened in 10.2.2. However, when I opened the MXD in ArcMap 10.0 on the server, it displayed two layers with issues. (a red explanation point). From there I used 10.0 to fix the layers.

Related Question