Print widget - Problem with custom request parameters

814
3
03-04-2021 12:25 AM
JerePallaskorpi
New Contributor

Hello,

We recently updated our ArcGIS JS API version from 4.13 to 4.18 and there seems to be a problem with sending custom request parameters for Print widgets' printServiceUrl.

Basically we have our own proxy/api ("/api/GPServer/Export Web Map") for printing, and we require some extra request parameters so we can highlight the selected features on the map for the print.

https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print.html

 

const print = new Print({
	view,
	printServiceUrl: "/api/GPServer/Export Web Map?customPrintParameters={example: parameters}"
});

 

We pass extra request parameters to Print widgets' printServiceUrl, but the request parameter (customPrintParameters) is always null in our backend api when the print widget is used within the app.

This was working fine with v4.13. Is this behaviour intended and is there some other way the custom request parameters could be sent to our backend with the Print widget? 

0 Kudos
3 Replies
ReneRubalcava
Frequent Contributor

Can you add them to the PrintParameters.extraParameters property?

https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintParameters.htm...

 

That should be how custom parameters are sent. I'm surprised it worked before in the print service url, technically I don't think it should have.

0 Kudos
JerePallaskorpi
New Contributor

Hmm, doesn't this mean we would need to switch from the Print widget to PrintTask, or is there some way the PrintParameters can be applied to the Print widget? It seems like lots of extra work to switch to PrintTask and according to some samples I found we would lose the widget window that includes all the file formats/layout options etc.

It has been extremely simple just to add the extra parameters to the Print widgets' printServiceUrl.

0 Kudos
Noah-Sager
Esri Regular Contributor
We are considering this for a future enhancement of the Print widget. In the meantime:
 
 
If not, it looks like the print() method on the ViewModel can pass a PrintTemplate: https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-PrintViewModel.html...
 
0 Kudos