Definition Expression not working in WebMapAsJson for print service

565
6
09-24-2018 05:12 PM
EllaHaines
New Contributor III

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.


 "operationalLayers": [
      {
         ...
      },
      {
         "id": "MapService",
         "title": "Field Report",
         "opacity": 1,
         "minScale": 0,
         "maxScale": 0,
         "layers": [
            {
               "name": "FieldReport", //does this need to be the layer name?
               "id": 0,
               "layerDefinition": {
                  "definitionExpression": "ReportID='[GUID]'"
               }
            },
            {
               "name": "PhotoInfo",
               "id": 1,
               "layerDefinition": {
                  "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:

ExportWebMap specification—ArcGIS REST API: Services Directory | ArcGIS for Developers 

0 Kudos
6 Replies
TanuHoque
Esri Regular Contributor

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?

EllaHaines
New Contributor III

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. 

0 Kudos
EllaHaines
New Contributor III

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.

0 Kudos
TanuHoque
Esri Regular Contributor

thanks.

I see why you want to generate json yourself.

I hope you won't mind if I recommend you to contact Esri Support at this point.

0 Kudos
EllaHaines
New Contributor III

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.

0 Kudos
TanuHoque
Esri Regular Contributor

Hi Ella,

it is very odd that def query does not work with standardized queries option is enabled !!

could you pls do me a favor?

  • log on to the server machine that hosts your print service
    • you need to log on as a user that runs ArcGIS SOC process (aka ArcGIS Server Account or SOC user)
  • download and start Fiddler
  • submit the print job from your app
  • monitor the requests that get sent to the map service from the print service
  • check what kind of error message that map service returns
  • also, see whether you can repro this by submitting a request to the map service from a web browser.

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.

Thanks.

Tanu

0 Kudos