Problem with print widget

06-06-2020 11:17 AM
New Contributor

I have custom web application using ArcGIS Api for Javascript 3.32 and trying to implement export map. I am using the same code as here: Print templates with esri.request | ArcGIS API for JavaScript 3.32 

But always getting this error:

TypeError: Cannot read property '3' of null
    at new h (init.js:457)
    at b.hasSameOrigin (init.js:731)
    at init.js:731
    at Object.some (init.js:70)
    at Object.b.canUseXhr (init.js:731)
    at A (init.js:958)
    at f (init.js:966)
    at H (init.js:974)
    at init.js:974
    at c (init.js:104)

As a Print Task I am using this: Task: Export Web Map Task 

Not sure where is the problem. Any help?

0 Kudos
3 Replies
Esri Regular Contributor

Couple suggestions:

1) can you share an app on something like codepen? the minimal code required to reproduce the issue, it's real tricky to figure this out from just the error message

2) try using the ArcGIS Online utility print service. sampleServer6 really isn't meant for anything other than our samples: 

3) have you tried 4x? You might find it a lot easier and more powerful: Print widget | ArcGIS API for JavaScript 4.15 

0 Kudos
New Contributor

Thanks for your reply Noah. I found where the error was. I am using secure services from my ArcGIS Online Organization and using token to authorize them in the code. When I authorize with IdentityManager like this then I have problem with print service:

var tokenMap = {
   'server': MapServiceUrl,
   'token': myToken,

Now I use the token on this way and don't have problem with the print service:

var newTiledLayer = new ArcGISTiledMapServiceLayer(MapServiceUrl + "?token=" + myToken, {
   visible: false

2) About the print service, is it possible somehow to add my own Print Layouts? I have ArcGIS Online Organization and if I go to Organization -> Settings -> Utility Services here I have Printing but I can't add my print service and then add my Print Layouts. Is it possible with ArcGIS Online Organization to have my own Print Service with my Print Layouts or only possible for printing is to use yours with the default Print Layouts: 

0 Kudos
Esri Regular Contributor

Great, glad you figured out the printing issue.

For custom Print Layouts, you need an authoring tool like ArcGIS Pro, and ArcGIS Server to host the print service. 

Printing in web applications—Documentation (10.7) | Documentation for ArcGIS Enterprise 

0 Kudos