I'm building a custom WebMapAsJson to pass to a print service, and for whatever reason, when I add the "layerDefinition" part, I am getting a 404. If I remove the layerDefinition objects, it seems to return the printed image just fine.
"title": "Field Report",
"name": "FieldReport", //does this need to be the layer name?
"definitionExpression": "FeatureID ='[GUID]'"
"url": "xxxx" //(public service)
Do I need to enable something like dynamic map services, or have a certain version of arcgis server for this to work? Trying to follow the instructions here:
That is odd. The json looks good to me.
the 'name' property in element insider 'layers' array is not needed. I don't think print service uses that.
you don't need to enable dynamic-layers capability when def queries need to be modified.
are you passing json to a print service formatted or unformatted? I'd try with unformatted.
is your json too large that hit the limit for the webserver GET request? I'd try with POST in that case.
if you don't mind and if I may - why are you building webmapasjson yourself instead of using arcgis JS API?
We are trying to get a map image to include in a report - without displaying the map on the website. The user just wants to click a single button to get the report.
I think I will have to use the JS API somewhat, to get the extent of the data and create the definition query, but I won't have an actual map I can pass to the print service. We are probably going to just use the print task and pass the resulting image url to the report.
I tried deleting other parts of the json and also using POST, and both of those sort of seem to be working (or at any rate, I'm not getting a 404), except I don't see any of the data now. I'm going to try messing around with the definition query some more and see if that helps.
Update: it seems the definition queries are valid and do show data at the center of the extent, at least when I try using the same definition queries in the mxd for the map service. When I use the print service without the definition query but the same extent, it shows the data (along with everything else). I'm not sure what's going on, or why the POST method wouldn't be showing anything but the basemap.
Think I figured out the issue, there were multiple problems:
1) As you mentioned, I did need to use POST because the JSON was too large;
2) While I was debugging, I enabled dynamic map services hoping that would fix it, and then kept them on - that was a mistake. It worked once I turned them off again. See this thread for reference: PrintTask. Bug with layer definitions and/or standardized queries?
We are still using ArcServer 10.3, however, so you'd think #2 wouldn't be a problem since everyone thinks it started with 10.5 in the other thread.
it is very odd that def query does not work with standardized queries option is enabled !!
could you pls do me a favor?
If that does not provide much clue, could you pls send me a small sample dataset and map etc. to help me reproduce this issue on my machine. I need to take a look at this and have it fixed.