layerDefs issue

3723
2
Jump to solution
02-10-2017 03:54 PM
JimNoel
New Contributor III

Ever since upgrading to ArcGIS Server 10.5, we've been having problems with some older (Flex) websites that access our REST services.  Whenever a map request involves filtering a layer via layerDefinitions, the map doesn't draw and we get this error:

      {"error":{"code":400,"message":"Invalid 'layerDefs' is specified","details":[]}}

We've determined that this is because 10.5 now requires layerDefs to be expressed in JSON format rather than Simple Syntax.  For example, one site might make a request like this:

https://alaskafisheries.noaa.gov/arcgis/rest/services/ShoreZoneFlexMapService/MapServer/export?size=... 

which doesn't work.  To work correctly, it has to look like this:

https://alaskafisheries.noaa.gov/arcgis/rest/services/ShoreZoneFlexMapService/MapServer/export?size=... 

As far as I can tell, there's no way to change the way the Flex API formats the LayerDefs parameter in the request.  And since ESRI is no longer supporting Flex, I'm not expecting to see any update on the Flex API to handle this.

I'm wondering if there is a way to get our server to rewrite the incoming request to change the layerDefs from Simple Syntax to JSON?  I've tried using URL Rewrite in IIS -- even at the global level -- but I'm still getting

      {"error":{"code":400,"message":"Invalid 'layerDefs' is specified","details":[]}}

so the rewrite isn't affecting the REST service request.  Perhaps the REST service has its own redirect that bypasses my URL Rewrite rule?

Any ideas on this?

0 Kudos
1 Solution

Accepted Solutions
DuarteCarreira
Occasional Contributor II

Hi Jim.

Take a look at this thread:

imageparameters.layerDefs does not work with 10.5

It doesn't work with the js api either and this is the supported api.

I don't know flex but it may be possible to reproduce the js workaround in flex.

Another option is to adapt esri's resource proxy to change the layerdefs parameter on the fly, instead or IIS rewrites.

Good luck.

View solution in original post

2 Replies
DuarteCarreira
Occasional Contributor II

Hi Jim.

Take a look at this thread:

imageparameters.layerDefs does not work with 10.5

It doesn't work with the js api either and this is the supported api.

I don't know flex but it may be possible to reproduce the js workaround in flex.

Another option is to adapt esri's resource proxy to change the layerdefs parameter on the fly, instead or IIS rewrites.

Good luck.

JimNoel
New Contributor III

Thanks, Duarte.  I had seen that thread before.  Unfortunately, in Flex the ArcGISDynamicMapServiceLayer class doesn’t seem to have an equivalent to _params, so I couldn’t find a way to intercept the request parameter to modify it.

 

However, I did look into your alternative suggestion of using and modifying the ESRI proxy page, and finally had success with that.  I had to dig into proxy.ashx, and add some code to the ProcessRequest method.  Using the modified proxy page, all requests to our REST services using the old format seem to be correctly translating to JSONP format now.

 

Thanks for the suggestion!  If anyone is interested, I can post my code.

0 Kudos