Hi Leo,
General the token and analysis url parameters are more complex on this case to be retrieved.
you have to follow the steps here:
Programmatically accessing analysis services—ArcGIS REST API: Spatial Analysis Service | ArcGIS for ...
in order to take the token and the analysis url for the PlanRoute task.
then see here for more details about the PlanRoute task
Plan Routes—ArcGIS REST API: Spatial Analysis Service | ArcGIS for Developers
In your case now at the beginning add this :
esriConfig.defaults.io.corsEnabledServers.push("analysis1.arcgis.com");
esriConfig.defaults.io.corsEnabledServers.push("www.arcgis.com");
urlUtils.addProxyRule({
urlPrefix: "https://analysis1.arcgis.com",
proxyUrl: "http://<machine>/proxy/proxy.ashx"
});
later on your code when you set the analysis service url:
.....
analysisTools = new PlanRoutes({
// startLayer: "",
// endLayer: "",
analysisGpServer: "https://analysis1.arcgis.com/arcgis/rest/services/tasks/GPServer/PlanRoutes/submitJob",
portalUrl: "http://www.arcgis.com/",
FeatureLayers: [schoolLayer, stopLayer],
returnToStart: false,
showChooseExtent: false,
.........
on the proxy page I am using the following:
<serverUrl url="https://analysis1.arcgis.com/arcgis/rest/services"
accessToken="xxxxxxxxxxxxxxxx"
matchAll="true"/>
in order to retrieve the token for your portal use this url
https://www.arcgis.com/sharing/generateToken?f=json&request=gettoken&username=<username>&password=<p...
but you also can use the clientId and the clientSecret in order to generate the token.
by doing that the PlanRoutes submit request is working

after that see the PlanRoutes settings Plan Routes—ArcGIS REST API: Spatial Analysis Service | ArcGIS for Developers in order to make it return results
