webmap from json with token

Discussion created by gknight on Mar 2, 2014
Latest reply on Mar 3, 2014 by gknight

I am trying to embed a webmap with a demographics layer in an application. 

Ive followed much of the advice provided in this thread here:


I am able to render the map/layer without a login, but I am getting some httpCode '498' | 'Invalid Token' | 'Unable to draw graphic (geometry: null, symbol: null) : Invalid Token' errors. There 6 of these for my webmap which includes 2 basemap layers and 1 operational (household income) operational layer. Also the popups for the demographics layer do not work.

Here's what I'm doing:

1.  Call a server-side class to get a token.

2.  Set esri.id = null to suppress the login. (this works)

3.  Create the webmap from json.  I am including the token in the layer object for my operational layer.

 webmap.itemData = {
    "operationalLayers": [{
      "url": "http://demographics1.arcgis.com/arcgis/rest/services/USA_Demographics_and_Boundaries/MapServer" + '?token=' + this.accessToken,
      "visibility": true,
      "opacity": 0.75,
      "title": "USA Average Household Income",
      "itemId": "3812e0b5526d4f8798840c86f9fd9ce7"

I have also tried iterating over the response to set the layerObject._url.query.token (per the above thread).  This isnt effective and seems unnecessary since my token value is is already sitting in that object key.

What am I missing here?

Thank you,