Select to view content in your preferred language

esri js api post for exportMap

2291
14
04-04-2017 11:35 AM
NicolasGIS
Frequent Contributor

Hello,

I have an arcgis ArcGISDynamicMapServiceLayer with quite a big number of "layerDefinitions" applied with the "setLayerDefinitions" method. 

The problem is that the GET export REST function of ArcGIS Server 10.4.1 (with webadaptor on IIS) does not work as the request is too big so a POST would be necessary.

It is stated in the documentation that "If the layer definition expression is longer than approximately 2000 characters you will need to set up a proxy page.". 

I configured the ESRI proxy GitHub project on my server and configured JS api (3.20) to always use the proxy:

esriConfig.defaults.io.proxyUrl = "<url_to_proxy>"
esriConfig.defaults.io.alwaysUseProxy = true;

The problem is that requests are still sent as GET operation so it does not work as well.

How am I supposed to tell JS API to POST for export map operation either directly to the REST api or to the proxy ?

Thanks for your help,

Nicolas

0 Kudos
14 Replies
ForrestCain1
Deactivated User

Hi Nicolas,

Did you ever find a solution to this issue?  I'm experiencing the same problem and also just being directed to use the proxy.

0 Kudos
NicolasGIS
Frequent Contributor

Hi Forrest,

Unfortunately not.

I would love an ESRI opinion on this issue but I finally ended up splitting my service so as to make it work ... It does not follow ESRI best practice to have one big service instead of several...

Nicolas

0 Kudos
ForrestCain1
Deactivated User
esriConfig.defaults.io.postLength = 1;

Nicolas, I found that setting the postLength to 1 (or any number smaller than your url) will force a post for all layers and tasks without using the proxy.  I don't see this documented anywhere but I do see in the api source code its checking this to determine to make a post.  When this happens, your request to the server comes back as some json with a url to an image.  The api automatically does another request to get this image and add it to the map (sorta like print task).  If you are using https, another problem occurs because the url you get back from the first request is in http (so you'll get mixed content warnings or errors).  I had to create a custom ArcGISDynamicMapServiceLayer using the createSubclass method and alter the getImageUrl function to swap it out to https.  I don't love it but its better than not working...

I have a ticket open with ESRI but so far they are just telling me to use the proxy...  I'm also really surprised more folks aren't having the same problem.  Maybe large layer defs and using https aren't an issue for most folks?

NicolasGIS
Frequent Contributor

Many thanks Forrest for the follow up. It is very interesting.

I am just like you very surprised that there is no others use cases (now we are 2 !).

Please let me know the outcome of your ticket ! I can't wait to read it

0 Kudos
NicolasGIS
Frequent Contributor

Hi Forrest,

Juste wondering if you had had any news from ESRI ?

Thanks

0 Kudos