routetask attributeparametervalue error

573
1
07-11-2013 04:19 PM
spencermartin
New Contributor
I keep getting an "attributeparametervalues parameter is invalid" error with this code. Can someone see what I'm missing?

var APV = [
  {
      "attributeName": "Avoid Limited Access Roads",
      "parameterName": "Restriction Usage",
      "value": "Avoid_Medium"
  }
    ];

    routeTask = new esri.tasks.RouteTask("https://tasks.arcgisonline.com/ArcGIS/rest/services/NetworkAnalysis/ESRI_Route_NA/NAServer/Route");
    routeParams = new esri.tasks.RouteParameters();
    routeParams.stops = new esri.tasks.FeatureSet();
    routeParams.barriers = new esri.tasks.FeatureSet();
    routeParams.returnRoutes = true;
    routeParams.returnDirections = true;
    routeParams.directionsLengthUnits = esri.Units.MILES;
    routeParams.outSpatialReference = new esri.SpatialReference({ wkid: 102100 });
    routeParams.restrictionAttributeNames = ["Avoid Limited Access Roads"];
    routeParams.attributeParameterValues = APV;
0 Kudos
1 Reply
DmitryKudinov
Occasional Contributor
Hi S Martin,

great to hear back from you again - thanks for coming to the UC this year!

The source code looks correct; the only thing which you need to change though is the route service it points at - the one your app currently uses is an old 10.0 SP4 ArcGIS Server. 'Soft Restrictions' which we were talking about were introduced in 10.1.

Please change you app to point at https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World instead. Since the latter is secured, you will need and organizational account (you can get a free 30-days trial account here https://www.arcgis.com/home/signin.html);, also do not forget to add the 'esri.IdentityManger' to the 'require' section. Here is an example of how to access a secured route REST endpoint: https://nadev.arcgis.com/arcgis/samples/RouteTaskEx/wwBarriers.html

One more thing:
[INDENT]{
"attributeName": "...",
"parameterName": "Restriction Usage",
"value": <value>
}[/INDENT]

- the <value> above can be represented by string constants as well as by a number of type double. See more details here: http://resources.arcgis.com/en/help/arcgis-rest-api/02r3/02r300000036000000.htm

(BTW, tasks.arcgisonline.com is a sample server which will be shut down by the end of this year, so do not use it in production)


Hope this will be helpful.

Dmitry
0 Kudos