Routing Issue

669
5
09-27-2018 09:54 AM
JohnBridges1
New Contributor

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

                        }

                    }];

                }

            }];

        }

    }];

0 Kudos
5 Replies
Nicholas-Furness
Esri Regular Contributor

Hi,

Try using this URL: https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World 

Also, take a look at this for an example of using the tasks.

Let me know if that helps.

0 Kudos
JohnBridges1
New Contributor

Nicholas,

Thanks, I appreciate your help, that works. Any reason why the other url did not?

JB

0 Kudos
Nicholas-Furness
Esri Regular Contributor

Hey John Bridges.

The other URL was nearly there. This is just how we published the world routing service. We're working on better documentation to make this easier to discover.

Cheers,

Nick

0 Kudos
JohnBridges1
New Contributor

Thanks again.

0 Kudos
ManasaParida
New Contributor III

John Bridges‌ i need a help on this re-routing, whenever we are navigating the wrong way from the list which we already have the route details as maneuvers, so could you please.

0 Kudos