AnsweredAssumed Answered

Routing Issue

Question asked by bhenson on Sep 27, 2018
Latest reply on Sep 30, 2018 by mannai_ios_manasa

Having an issue with routing and secured route service. I have a simple Objective-C app with one view and am using iOS_100_3 version of the sdk. In viewDidLoad I am basically doing the following. When I run this I get the following error from loadWithCompletion

 

Error Domain=com.esri.arcgis.runtime.error Code=18 "Internal error" UserInfo={NSLocalizedFailureReason=Cannot get required value. Probably, invalid JSON., NSLocalizedDescription=Internal error, Additional Message=Cannot get required value. Probably, invalid JSON.}

 

Using this same basic code but replacing the route url with 

https://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/NAServer/Route

I do not see the above error, I get another error which is expected as the code is not complete.

 

I feel it might be related to how I am authenticating with the route service, but am not sure as the error only tells me JSON might be invalid.

 

Has anyone here seen this or have any suggestions? Thanks.

 

 

 NSURL *routeTaskUrl = [NSURL URLWithString:@"http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/"];

    self.routeTask = [[AGSRouteTask alloc] initWithURL:routeTaskUrl];

    AGSCredential *cred = [AGSCredential credentialWithUser:@"xxxxxx"  password:@"xxxxxx"];

    [self.routeTask setCredential:cred];

 

[self.routeTask loadWithCompletion:^(NSError *error){

        if(error)

        {

            NSLog(@"%", error.localizedDescription);

        }

        else if(self.routeTask.loadStatus == AGSLoadStatusLoaded)

        {

            NSLog(@"route task loaded");

            [self.routeTask defaultRouteParametersWithCompletion:^(AGSRouteParameters * _Nullable routeParams, NSError * _Nullable error) {

                if(error)

                {

                    NSLog(@"%", error.localizedDescription);

                }

                else

                {

                    self.routeTaskParams = routeParams;

                    [self.routeTask solveRouteWithParameters:self.routeTaskParams completion:^(AGSRouteResult * _Nullable routeResult, NSError * _Nullable error) {

                        if(error)

                        {

                            NSLog(@"%", error.localizedDescription);

                        }

                        else

                        {

                            // do something with it

 

                        }

                    }];

                }

            }];

        }

    }];

Outcomes