How to pass a token with a Url in cedar Charts in leaflet.

70
0
05-14-2020 10:36 PM
Highlighted
New Contributor III

Passing a token in cedar charts.

Hi , I am trying to pass a token with my rest service Url into a dataset for drawing a cedar chart.

Here is the code.

============

var serviceurl = "https://myCompanyUrl/arcgis/rest/services/PORT_Construction_Inspection/ENG_CI_SERVICE_REQUESTS/MapServer/0"

var datasets = [{
   "url": serviceurl,
   "token": sessionStorage.getItem("token"),  //Here where I am passing the token
   "name": "ServiceRequests",
   "query": {
   "orderByFields": "Number_of_SUM DESC",
   "groupByFieldsForStatistics": "REQUEST_STATUS",
   "outStatistics": [{
   "statisticType": "count",
   "onStatisticField": "OBJECTID",
   "outStatisticFieldName": "Number_of_SUM"
         }]
   }
}];

// designate a one or more series to show the data on the chart
var series = [{
"category": { "field": "REQUEST_STATUS", "label": "Status" },
"value": { "field": "Number_of_SUM", "label": "Count" },
"source": "ServiceRequests"
}];

// optionally override any of the cart type's default styles
var overrides = {
"categoryAxis": {
"labelRotation": 0
}
}

//create a cedar chart using the known 'bar' type
var elementId = 'chart';

var chart = new cedar.Chart(elementId, { "type": "bar-horizontal" })
.datasets(datasets)
.series(series)
.overrides(style);
// render the chart
chart.show();

Here is my error. When I look at the Url below, I do not see the token concatenation. Is there a different way to pass a token.

  1. ArcGISAuthError
    1. code: 499
    2. message: "499: Token Required"
    3. name: "ArcGISAuthError"
    4. options: {httpMethod: "GET", params: {…}, headers: {…}, fetch: ƒ}
    5. originalMessage: "Token Required"
    6. response: {error: {…}}
    7. url: "https://myUrl.memphistn.gov/arcgis/rest/services/PORT_Construction_Inspection/ENG_CI_SERVICE_REQUESTS/MapServer/0/query?f=json&where=1%3D1&returnGeometry=false&returnDistinctValues=false&returnIdsOnly=false&returnCountOnly=false&outFields=*&sqlFormat=standard&orderByFields=SUPERVISOR_ZONE%20ASC&groupByFieldsForStatistics=SUPERVISOR_ZONE&outStatistics=%5B%7B%22statisticType%22%3A%22count%22%2C%22onStatisticField%22%3A%22OBJECTID%22%2C%22outStatisticFieldName%22%3A%22Number_of_SUM%22%7D%5D"
    8. __proto__: ArcGISRequestError
Reply
0 Kudos
0 Replies