0

i am new to using the TOMTOM API but i got it working with the example in the browser without a problem, call:

https://api.tomtom.com/routing/1/calculateReachableRange/50.97452,5.86605/json/?key=[MYKEY]&timeBudgetInSec=3600

in the browser i get my json response with my polygon point. But in python i just get the error stating:

"Invalid request: should contain one of the following elements 'avoidVignette' or 'allowVignette'"

Does anybody have any idea why it works in the browser but gives an error when i use it in python code?

mycode:

request_post = requests.post('https://api.tomtom.com/routing/1/calculateReachableRange/50.97452,5.86605/json/?key=[MYKEY]&timeBudgetInSec=3600')

thanks in advance

Liam
  • 545
  • 4
  • 11
  • You can't send POST requests "in the browser" (from a browser's address bar, I presume?), can you? – ForceBru Mar 26 '18 at 13:25
  • I just figured it out, there is the https url at the top of my question which you can past in the browser (if you have a key) and you will get the result you expect. – Liam Mar 26 '18 at 13:30

2 Answers2

1

I figured it out with the help of the comment of @ForceBru. I used postman to figure out what the problem was and it seems that if you do not use the link directly in the browser but use it as a real post request you are needed to give it a xml or json body where you need to specifiy:

{"avoidVignette": []}

if you are using json.

If you put this in your post request as body it should work like a charm. Working code:

requests.post('https://api.tomtom.com/routing/1/calculateReachableRange/50.97452,5.86605/json/?key=[MYKEY]&timeBudgetInSec=3600', json={"avoidVignette": []})

Hope this helps some people forward if they get the same error.

Liam
  • 545
  • 4
  • 11
0

If You are not providing any POST parameters than You can use GET method.

Here is the link to Online Routing API Explorer - link

szogoon
  • 470
  • 3
  • 15