Optimization service error

Hi,

First of all, many thanks for optimization service!!
It´s great and so fast!

But, I´m facing a problem running PHP example code:
I´ve copied and paste PHP Optimization example and I´m getting the following error:

"{"code":2,"error":"Invalid JSON object in request, please add jobs and vehicles to the object body"}"

I´ve also tried (copied & paste) Javascript version and it runs OK.
The data part of both (PHP & Javascript) are exactly the same.
So there is some option missing inside PHP version.

Yeah, the code there is auto-generated and generally not really to be trusted. I don’t really see the problem in the PHP code either, but that doesn’t say anything, don’t really PHP. I think you’ll just have to google how to make a POST request in PHP, it should be pretty easy.

Thanks Nils…

Maybe the problem is related when converting from PHP variable to JSON string because I´m using PHP curl POST for routing without any problem.

BTW… Now I´m getting “Daily quota reached or API key unauthorized”

Well, you only get 50 optimization per day: https://openrouteservice.org/plans/

Good luck

Hi @uerlings,
you might have to tweak the headers a bit. If you look through the other examples and try out some headers, you might solve this.
If you would provide a working example, we could adjust the example template and help others facing the same problem.

Best regards

I agree with you amandus: the problem is located at header
I will try changing header otions and post here when a fix is found.

Can you change (only for my user) the limit of 50 requests per day during this?

Regards

amandus,

It´s working now!
As you mentioned, the problem was at HEADER clause.

Please, add to PHP example code:

“Content-Type: application/json”,

as shown below:

url_setopt($ch, CURLOPT_HTTPHEADER, array(
“Accept: application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8”,
“Content-Type: application/json”,
“Authorization: your_auth_key”

));