Directions Widget (4.x) triggered custom service error; 3.x Working

2680
2
01-07-2022 01:42 PM
LucasScharenbroich
Occasional Contributor

I have a pre-existing, custom routing services that has been used successfully with the JSAPI 3.x for a couple of years.  We are in the process of updating to JSAPI 4.x and have run into a behavior issue where the built-in Directions widget is passing parameters to the `route` endpoint that are causing an error to be returned.

Specifically, the 3.x API includes

 

"simplificationTolerance":null,
"simplificationToleranceUnits":"esriUnknownUnits"

 

with the travelMode argument which the 4.x API does not.  These parameters do not appear to be exposed in the RouteParameters object, which required more .... invasive ... methods to override.

Without these travelMode parameters set, we get the following error response the the "solve" endpoint

 

{
  "error": {
    "code":400,
    "message":"Invalid or missing input parameters.",
    "details":["The following travel mode is invalid: ..."]
  }
}

 

 

Any recommendations on how to finess/configure the Direction widget to work around this issue; or perhaps even change how the Network Analyst service is published to make it friendlier to the JSAPI 4.x conventions?

 

Version Details
* ArcGIS Server 10.5.1
* Network Analyst Extension 10.5.1

0 Kudos
2 Replies
Noah-Sager
Esri Regular Contributor

Hi @LucasScharenbroich, I haven't encountered this scenario before. Would it be possible for you to share the routing service endpoint so I could do some testing? You could also message me directly if you don't want to share it on this post (if it's publicly accessible). Does it also use a custom locator?

It also may be possible that the 3x app overrides the travelMode, making it valid. If that's the case, you should be able to set the current travelMode using this property on the DirectionsViewModel: 

https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsView...

 

0 Kudos
Noah-Sager
Esri Regular Contributor

Hi @LucasScharenbroich, looks like we'll have this fixed in the next release (4.23), which is expected in late March.

0 Kudos