{Error code '498': 'Invalid Token'}

2570
0
10-28-2015 07:12 AM
MuralidharMoka1
New Contributor III

Hi,

We are migrating our silverlight application from 9.3 to 10.3.

       When we are trying to Query on a feature service. The following code works perfectly with ArcGIS server 9.3 service, but fails when we migrate the same service to 10.3. We used  ArcGIS Silverlight API (that is 2.4Ver) in both the cases.

                     QueryTask queryTask = new QueryTask(boundaryDefinition.Url);

                      queryTask.Token = "municiaplities";

                      queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;

                      queryTask.Failed += QueryTask_Failed;

We observed that the failing in 10.3 happens at line queryTask.Token = "municiaplities";  If we remove this line it works in 10.3 also.

    The error we received when it fails is this.                     {Error code '498': 'Invalid Token'}

    But we have to use line with the Token.( it is required for us).

How to solve this error. We need this urgently.

Here is the API used.

ArcGIS silverlight API 2.4  for 9.3 as well as 10.3. We don't know if we have to use another version for 10.3

Here is the complete code.

namespace ESRIStandardMapApplication1

{

    public partial class MainPage : UserControl

    {

        private List<BoundaryDefinition> boundaryDefinitionList = new List<BoundaryDefinition>();

        private List<TreeViewItem> tviBoundaryList = new List<TreeViewItem>();

        public List<CheckBox> CheckBoxSelectedList { get; set; }

        private int queryCount = 0;

        private class BoundaryDefinition

        {

            public String Name { get; set; }

            public String Url { get; set; }

            public List<String> OutFields { get; set; }

        }

        public MainPage()

        {

            InitializeComponent();

            initBoundaries();

            GetBoundaries();

     

        }

        private void initBoundaries()

        {

            boundaryDefinitionList.Add(new BoundaryDefinition()

            {

                Name = "Municipalities",

                //Url = "http://mapview3.memphistn.gov/ArcGIS/rest/services/BaseMaps/Basemap2010/MapServer/3",     //(9.3 )

                Url="http://memdmzgisprep1.memphisdmz.ad/arcgis/rest/services/LocalGovGIS/Basemap2010/MapServer/3", // (10.3)

                OutFields = new List<String>() { "OBJECTID", "CITY" }

            });

        }

        private void GetBoundaries()

        {

            foreach (BoundaryDefinition boundaryDefinition in boundaryDefinitionList)

            {

                queryCount++;

                QueryTask queryTask = new QueryTask(boundaryDefinition.Url);

          

                queryTask.Token = boundaryDefinition.Name;

                queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;

                queryTask.Failed += QueryTask_Failed;

                Query query = new Query();

                query.Geometry = Map.Extent;

                query.OutFields.AddRange(boundaryDefinition.OutFields);

                query.OutSpatialReference = Map.SpatialReference;

                query.ReturnGeometry = true;

                queryTask.ExecuteAsync(query);

            }

        }

        // Populate county commission boundaries back on council layer results

        private void QueryTask_ExecuteCompleted(object sender, QueryEventArgs e)

        {

            if (e.FeatureSet.Count() == 0)

            {

                //do some thing.

            }

            else

            {

                //code to get the URL

                BoundaryDefinition thisBoundaryDefinition = boundaryDefinitionList.FirstOrDefault(bd => bd.Name == ((QueryTask)sender).Token);

                string serviceUrl = thisBoundaryDefinition.Url;

            }

      

        }

        // Display notification of county commission layer query failure

        private void QueryTask_Failed(object sender, TaskFailedEventArgs e)

        {

     

        }

    }

}

Reply
0 Kudos
0 Replies