esri js api post for exportMap

1840
14
04-04-2017 11:35 AM
NicolasGIS
Occasional Contributor III

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
NicolasGIS
Occasional Contributor III

Really nobody for this ? Thought it was a relevant question as the problem can quickly occurs if using parameters such as "Dynamic Layers" with big services.

Have I missed anything ?

Any hint on the way to go would be great. 

Cheers,

Nicolas

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Nicolas,

   You will want to look at this link for adding proxy rules:

https://developers.arcgis.com/javascript/3/jsapi/esri.urlutils-amd.html#addproxyrule 

0 Kudos
NicolasGIS
Occasional Contributor III

Hello Robert,

Thanks for your reply.

I did have a look at your link before posting here and it did not solve my problem. Indeed, I added a rule as you suggested :

esri.addProxyRule({
      urlPrefix: "https://hostname/arcgis/rest/services/MyServiceWithLonglayerDefinitions/MapServer/export",
      proxyUrl: '/proxy.ashx'
});

And indeed, it works, my request is sent to the proxy but still with GET method, so it still get a 404 error.

I am reading everywhere that proxy should help to POST instead of GET but isn't suppose to POST by itself according to the size of the request ?

Thanks,

Nicolas

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

So you are saying that you see the request going through the proxy for the exportmap request but it is just not switching to POST?

0 Kudos
NicolasGIS
Occasional Contributor III

Exactly ! And I tried with several versions of ESRI javascript API (3.16,3.17,3.18,3.19,3.20) with the same results.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Nicholas,

   So you app is using the https protocol right? And you are using the latest version of the proxy 1.1.0 or 1.1.1-beta?

I tend to make my proxy rules a little less explicit:

esri.addProxyRule({
      urlPrefix: "https://hostname/arcgis/rest/services",
      proxyUrl: '/proxy.ashx'
});

0 Kudos
NicolasGIS
Occasional Contributor III

Thanks for your time Robert !

Yes, https is used.

I restricted the url but it did not change anything (at the beginning, in order to be sure, I configured all requests to be proxied:

esriConfig.defaults.io.alwaysUseProxy = true;

)

I am using latest esri Github .NET proxy 1.1.1 beta but isn't it more about javascript here ? The request does not reach the proxy unfortunately because of the use of GET method.


Thanks,

Nicolas

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Nicolas,

  I guess at this point you should open an esri tech support ticket then.

0 Kudos
NicolasGIS
Occasional Contributor III

Thanks Robert. I was hoping to get a reply from ESRI directly here but I guess I will open a ticket then...

Honestly I am surprised to be the first one asking : I was sure I missed something !

0 Kudos