PrintTask breaks with Vector Layers in 4.6?

142
1
01-03-2018 01:59 PM
AndrewLindley
New Contributor III

I have a 3D sceneView application that uses a work-around print function that creates a 2D map in the background from the same 'map' as the sceneView, and prints from that. This post explains the process: here. After switching to 4.6, having any feature layers or mapService layers turned to 'visible' in the sceneview, and thus the map view, causes the execute print task to fail. It doesn't throw any error in the console, just the error callback function. If I revert back to 4.5, with no changes in the code, it works perfectly. 

Just wanted to throw this out there if anyone else has noticed issues around printing in 4.6.

Cheers

Tags (1)
0 Kudos
1 Reply
AndrewLindley
New Contributor III

I think I'm narrowing in on the problem, but would still like some confirmation or insight if anyone is having a similar issue.

I've found that a token is being applied to the web-map-as-json object for image services, but not for feature services. This is what the auto-generated parsed json looks like from the execute task:

{
  "operationalLayers": [
    {
      "id": "164155056a1-layer-3",
      "title": "World Shaded Relief",
      "opacity": 1,
      "minScale": 0,
      "maxScale": 0,
      "url": "https://services.arcgisonline.com/arcgis/rest/services/World_Shaded_Relief/MapServer",
      "token": null
    },
    {
      "id": "164155056a1-layer-4",
      "title": "World Imagery",
      "opacity": 0.4,
      "minScale": 0,
      "maxScale": 0,
      "url": "https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer",
      "token": null
    },
    {
      "id": "worldElevation",
      "title": "Terrain3D",
      "opacity": 1,
      "minScale": 0,
      "maxScale": 0,
      "url": "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer",
      "token": null
    },
    {
      "id": "164155056a1-layer-5",
      "title": "Name of Image Service",
      "opacity": 1,
      "minScale": 0,
      "maxScale": 0,
      "url": "https://path_to_image_service/ImageServer",
      // TOKEN //
      "token": "token_registered_with_ID_manager.",
      "format": "jpgpng",
      "mosaicRule": {
        "mosaicMethod": "esriMosaicAttribute",
        "where": "group_name LIKE 'Monitoring'",
        "sortField": "imagery_date",
        "sortValue": "1488326400000",
        "mosaicOperation": "MT_LAST"
      }
    },
    {
      "id": "16415505679-layer-0",
      "opacity": 1,
      "title": "Feature Service Name",
      "url": "https://path_to_feature_service/FeatureServer/0",
      "visibility": true,
      "layerType": "ArcGISFeatureLayer",
      "showLabels": true
      // NO TOKEN PROPERTY //
    }
  ],
  "mapOptions": {
    "extent": {
      "spatialReference": {
        "latestWkid": 3857,
        "wkid": 102100
      },
      "xmin": -8983724.50840311,
      "ymin": 4791756.402744357,
      "xmax": -8953149.697089082,
      "ymax": 4801960.746020414
    },
    "spatialReference": {
      "latestWkid": 3857,
      "wkid": 102100
    },
    "rotation": -0.9701294052936191,
    "scale": 8233
  },
  "exportOptions": {
    "dpi": 96
  },
  "layoutOptions": {
    "titleText": "",
    "authorText": "",
    "copyrightText": "",
    "scaleBarOptions": {},
    "legendOptions": {
      "operationalLayers": [
        {
          "id": "16415505679-layer-0"
        },
        {
          "id": "16415505681-layer-1"
        },
        {
          "id": "16415505682-layer-2"
        }
      ]
    }
  }
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I removed some sensitive info, but suffice to say the print works fine if I include only the image service, but if I include a feature service I get an error like: "Failed to create layer from service at https://path_to_feature_service".

ALSO: If I manually add the token property to the feature service object in the web-map json and run that directly from the print service endpoint, it works like a charm.

So my working theory is that the API is not appending a necessary token to all secure map layers, but only to image services. I find it strange that there is even a 'token' property in the ESRI layer objects, but not in our feature service objects.

Any ideas?

0 Kudos