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
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.