Closed TimoRuetten closed 5 years ago
Can you provide the underlying network request that was made or a code snippet?
Of course. I am using your graphhopper-js-api-client client. An example request looks like this:
const ghRouting = new GraphHopperNotOptimization({
key,
vehicle: 'car',
elevation: false,
});
ghRouting.doRequest({
vehicles: [vehicle],
// ...
vehicle_types: [{
type_id: 'vehicle_type_1',
profile: 'car',
}],
services,
}).then(() => {}).catch(() => {});
The catch always return just "Bad Request" when something seems to be wrong. It was a bit hard to make everything work without exactly knowing what the matter was.
Ok, thanks! This should be fixed now, will be uploaded soonish.
For future reference this is the way to query the Route Optimization API:
const ghRO = new GraphHopper.Optimization({key: "your_key"});
ghRO.doRequest(requestJsonWithSyntaxError).
then( function(json){console.log(json)}).
catch(function(json){console.log(json)});
0.11.1 was published :)
Great - thanks!
Thanks for your fast response and making the package better for debugging when something went wrong :)
Cheers
Its a bit hard to work with the npm package because when doRequest does not work it seems that the only return error message is that there is a bad request.
I was able to make a request work. Then I changed the address data for the services of the optimized route and all I get was "Bad Request".
After checking my code I saw that the lat/lng were strings instead of floats. After changing it it worked fine.
It would be nice if the returned error would give some hints what the problem could be.