Print Widget Error, Unexpected Token "<"

09-18-2018 08:26 AM
New Contributor

I am trying to use a locally hosted print service (GPServer) within the Print Widget in AGOL, but an error is returned when a map is requested. This print service is utilized with other applications in our organization and there has never been an issue with the widget's performance. The application uses AGOL hosted point data that is not secured (shared with "everyone") and the print service is also publicly accessible by anyone using the rest endpoint. I will attach a screenshot of the current issue, but in short when trying to print a map (pdf) of viewable data the widget is unable to complete the request and the following error is returned: "Unexpected token <". This error only occurs within this application and only when trying to print a map of greater than ~4,000 point features; less than ~4,000 features does not return this error and a map/pdf is successfully generated and returned. 

In troubleshooting this issues I have done the following and the issue has persisted:

1. Changed sharing from "Organization" to "Everyone" for all associated layers.

2. Changed print service's "Maximum Number of Records Returned by Server" from 1,000 to 100,000

3. Changed print service's "The maximum time a client will wait to get a service" and "The maximum time a client can use a service" to 6,000

4. Changed point data layers "Max Record Count" from 1,000 to 100,000

In other semi-related GEONET postings, I have read about an issue with the print widget sending/receiving the JSON data in an HTML string format and the widget is unable to parse that information correctly. Could this be a similar issue? If so, how would this be resolved?

Attached you will find screenshots of the issue as well as the configuration of the Print Widget.

0 Kudos
6 Replies
Occasional Contributor

I am also having this issue with a GP service and experience the same issue with the service succeeding for less than approximately 4,000 points but failing for more than that with the message "Unexpected token '<'."

Were you ever able to find a solution?

0 Kudos
New Contributor II

I, too, have been going around and around with this print widget issue for quite some time. On occasion everything works great, but it's the exception rather than the rule. The error happens on multiple machines and in different browsers. Perhaps I need to simplify my map. Judging from the previous thread, it does appear that the quantity of point data can make or break the print widget, although I have this happen even with all my point data turned off. Generally, I have to open the map in desktop, create a layout, and print from that.

Very frustrating!

0 Kudos
Esri Regular Contributor


1. if you have newer version of server (such as 10.6.1 and above), I'd ask you to try with the default out of the box print service (that comes installed with the server) or publish one from ArcGIS Pro

Share a print service web tool with custom layouts from ArcGIS Pro—Documentation (10.7) | ArcGIS Ent... 

2. if you could attach the json string that gets sent to a print service, I can take a quick look.


0 Kudos
New Contributor II

I'm afraid I'm trying to print at a much simpler level than server. I'm trying to print from the standard print widget in a basic AGOL app created in Web AppBuilder.. Maybe I'm expecting too much, but it does work fine on occasion.

0 Kudos
Esri Regular Contributor

Standard print widget does the exactly same thing - it generates a json string and submits the job to the default agol print service.

you can use Fiddler or your web browser Developers Tool's Network tab to extract that json.

0 Kudos
New Contributor II

Well, i guess I don't know just what I'm looking for as far as identifying the json string  that gets sent to a print service. I opened the developer tools in the browser, but I'm in over my head regarding finding what I need.

For the error itself, I see:

SyntaxError: Unexpected token '<'
at Object.b.fromJson (init.js:133)
at Object.json (init.js:85)
at w (init.js:89)
at c (init.js:104)
at e (init.js:104)
at b.Deferred.resolve.callback (init.js:105)
at init.js:93
at m (init.js:108)
at k (init.js:108)
at e.resolve (init.js:110)

Seems like it may just be timing out as I also see: 504 (GATEWAY_TIMEOUT)

Out of the blue, it did print once a few minutes ago, but then back to the same thing.

0 Kudos