<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic layerDefs issue in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/layerdefs-issue/m-p/214682#M19875</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ever since upgrading to ArcGIS Server 10.5, we've been having problems with some older (Flex) websites that access our REST services. &amp;nbsp;Whenever a map request involves filtering a layer via&amp;nbsp;layerDefinitions, the map doesn't draw and we get this error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{"error":{"code":400,"message":"Invalid 'layerDefs' is specified","details":[]}}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We've determined that this is because 10.5 now requires layerDefs to be expressed in JSON format rather than&amp;nbsp;Simple Syntax. &amp;nbsp;For example, one site might make a request like this:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://alaskafisheries.noaa.gov/arcgis/rest/services/ShoreZoneFlexMapService/MapServer/export?size=950%2C540&amp;amp;imageSR=102100&amp;amp;transparent=true&amp;amp;dpi=96&amp;amp;f=image&amp;amp;bbox=-16445389%2E266341925%2C5254576%2E417854222%2C-11798017%2E946604446%2C7896240%2E115389209&amp;amp;bboxSR=102100&amp;amp;format=png8&amp;amp;layerDefs=3%3AState%3D%27AK%27" title="https://alaskafisheries.noaa.gov/arcgis/rest/services/ShoreZoneFlexMapService/MapServer/export?size=950%2C540&amp;amp;imageSR=102100&amp;amp;transparent=true&amp;amp;dpi=96&amp;amp;f=image&amp;amp;bbox=-16445389%2E266341925%2C5254576%2E417854222%2C-11798017%2E946604446%2C7896240%2E115389209&amp;amp;bboxSR=102100&amp;amp;format=png8&amp;amp;layerDefs=3%3AState%3D%27AK%27"&gt;https://alaskafisheries.noaa.gov/arcgis/rest/services/ShoreZoneFlexMapService/MapServer/export?size=950%2C540&amp;amp;imageSR=10…&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which doesn't work. &amp;nbsp;To work correctly, it has to look like this:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://alaskafisheries.noaa.gov/arcgis/rest/services/ShoreZoneFlexMapService/MapServer/export?size=950%2C540&amp;amp;imageSR=102100&amp;amp;transparent=true&amp;amp;dpi=96&amp;amp;f=image&amp;amp;bbox=-16445389%2E266341925%2C5254576%2E417854222%2C-11798017%2E946604446%2C7896240%2E115389209&amp;amp;bboxSR=102100&amp;amp;format=png8&amp;amp;layerDefs={%223%22%3A%22State%3D%27AK%27%22}" title="https://alaskafisheries.noaa.gov/arcgis/rest/services/ShoreZoneFlexMapService/MapServer/export?size=950%2C540&amp;amp;imageSR=102100&amp;amp;transparent=true&amp;amp;dpi=96&amp;amp;f=image&amp;amp;bbox=-16445389%2E266341925%2C5254576%2E417854222%2C-11798017%2E946604446%2C7896240%2E115389209&amp;amp;bboxSR=102100&amp;amp;format=png8&amp;amp;layerDefs={%223%22%3A%22State%3D%27AK%27%22}"&gt;https://alaskafisheries.noaa.gov/arcgis/rest/services/ShoreZoneFlexMapService/MapServer/export?size=950%2C540&amp;amp;imageSR=10…&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As far as I can tell, there's no way to change the way the Flex API formats the LayerDefs parameter in the request. &amp;nbsp;And since ESRI is no longer supporting Flex, I'm not expecting to see any update on the Flex API to handle this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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? &amp;nbsp;I've tried using URL Rewrite in IIS -- even at the global level -- but I'm still getting&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;{"error":{"code":400,"message":"Invalid 'layerDefs' is specified","details":[]}}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so the rewrite isn't affecting the REST service request. &amp;nbsp;Perhaps the REST service has its own redirect that bypasses my URL Rewrite rule?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas on this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Feb 2017 23:54:55 GMT</pubDate>
    <dc:creator>JimNoel</dc:creator>
    <dc:date>2017-02-10T23:54:55Z</dc:date>
    <item>
      <title>layerDefs issue</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/layerdefs-issue/m-p/214682#M19875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ever since upgrading to ArcGIS Server 10.5, we've been having problems with some older (Flex) websites that access our REST services. &amp;nbsp;Whenever a map request involves filtering a layer via&amp;nbsp;layerDefinitions, the map doesn't draw and we get this error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{"error":{"code":400,"message":"Invalid 'layerDefs' is specified","details":[]}}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We've determined that this is because 10.5 now requires layerDefs to be expressed in JSON format rather than&amp;nbsp;Simple Syntax. &amp;nbsp;For example, one site might make a request like this:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://alaskafisheries.noaa.gov/arcgis/rest/services/ShoreZoneFlexMapService/MapServer/export?size=950%2C540&amp;amp;imageSR=102100&amp;amp;transparent=true&amp;amp;dpi=96&amp;amp;f=image&amp;amp;bbox=-16445389%2E266341925%2C5254576%2E417854222%2C-11798017%2E946604446%2C7896240%2E115389209&amp;amp;bboxSR=102100&amp;amp;format=png8&amp;amp;layerDefs=3%3AState%3D%27AK%27" title="https://alaskafisheries.noaa.gov/arcgis/rest/services/ShoreZoneFlexMapService/MapServer/export?size=950%2C540&amp;amp;imageSR=102100&amp;amp;transparent=true&amp;amp;dpi=96&amp;amp;f=image&amp;amp;bbox=-16445389%2E266341925%2C5254576%2E417854222%2C-11798017%2E946604446%2C7896240%2E115389209&amp;amp;bboxSR=102100&amp;amp;format=png8&amp;amp;layerDefs=3%3AState%3D%27AK%27"&gt;https://alaskafisheries.noaa.gov/arcgis/rest/services/ShoreZoneFlexMapService/MapServer/export?size=950%2C540&amp;amp;imageSR=10…&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which doesn't work. &amp;nbsp;To work correctly, it has to look like this:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://alaskafisheries.noaa.gov/arcgis/rest/services/ShoreZoneFlexMapService/MapServer/export?size=950%2C540&amp;amp;imageSR=102100&amp;amp;transparent=true&amp;amp;dpi=96&amp;amp;f=image&amp;amp;bbox=-16445389%2E266341925%2C5254576%2E417854222%2C-11798017%2E946604446%2C7896240%2E115389209&amp;amp;bboxSR=102100&amp;amp;format=png8&amp;amp;layerDefs={%223%22%3A%22State%3D%27AK%27%22}" title="https://alaskafisheries.noaa.gov/arcgis/rest/services/ShoreZoneFlexMapService/MapServer/export?size=950%2C540&amp;amp;imageSR=102100&amp;amp;transparent=true&amp;amp;dpi=96&amp;amp;f=image&amp;amp;bbox=-16445389%2E266341925%2C5254576%2E417854222%2C-11798017%2E946604446%2C7896240%2E115389209&amp;amp;bboxSR=102100&amp;amp;format=png8&amp;amp;layerDefs={%223%22%3A%22State%3D%27AK%27%22}"&gt;https://alaskafisheries.noaa.gov/arcgis/rest/services/ShoreZoneFlexMapService/MapServer/export?size=950%2C540&amp;amp;imageSR=10…&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As far as I can tell, there's no way to change the way the Flex API formats the LayerDefs parameter in the request. &amp;nbsp;And since ESRI is no longer supporting Flex, I'm not expecting to see any update on the Flex API to handle this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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? &amp;nbsp;I've tried using URL Rewrite in IIS -- even at the global level -- but I'm still getting&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;{"error":{"code":400,"message":"Invalid 'layerDefs' is specified","details":[]}}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so the rewrite isn't affecting the REST service request. &amp;nbsp;Perhaps the REST service has its own redirect that bypasses my URL Rewrite rule?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas on this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2017 23:54:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/layerdefs-issue/m-p/214682#M19875</guid>
      <dc:creator>JimNoel</dc:creator>
      <dc:date>2017-02-10T23:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: layerDefs issue</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/layerdefs-issue/m-p/214683#M19876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jim.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Take a look at this thread:&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/message/668973-re-imageparameterslayerdefs-does-not-work-with-105"&gt;imageparameters.layerDefs does not work with 10.5&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It doesn't work with the js api either and this is the supported api.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know flex but it may be possible to reproduce the js workaround in flex.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another option is to adapt esri's resource proxy to change the layerdefs parameter on the fly, instead or IIS rewrites.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Mar 2017 16:50:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/layerdefs-issue/m-p/214683#M19876</guid>
      <dc:creator>DuarteCarreira</dc:creator>
      <dc:date>2017-03-01T16:50:56Z</dc:date>
    </item>
    <item>
      <title>Re: layerDefs issue</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/layerdefs-issue/m-p/214684#M19877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;Thanks, Duarte.&amp;nbsp; I had seen that thread before.&amp;nbsp; 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.&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;However, I did look into your alternative suggestion of using and modifying the ESRI proxy page, and finally had success with that.&amp;nbsp; I had to dig into proxy.ashx, and add some code to the ProcessRequest method.&amp;nbsp; Using the modified proxy page, all requests to our REST services using the old format seem to be correctly translating to JSONP format now.&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;Thanks for the suggestion!&amp;nbsp; If anyone is interested, I can post my code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Mar 2017 21:42:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/layerdefs-issue/m-p/214684#M19877</guid>
      <dc:creator>JimNoel</dc:creator>
      <dc:date>2017-03-06T21:42:27Z</dc:date>
    </item>
  </channel>
</rss>

