Roads-Realtime Request Body

Hi,
I have been looking at the Roads-Realtime Api both through the API Explorer and a Python script but cannot seem to get it to work. I know my API key and authorization is working as it works with https://api.transport.nsw.gov.au/v1/ttds/events but i cannot get it to work with https://api.transport.nsw.gov.au/v1/ttds/route.

I followed the instructions as per the example in API Explorer and have set the X-User-Agent and Content-Type correctly and set the body to

“encoded-paths”: [“jsumEge|y[t@FpId@`@BToCtAHrAJ~@GXBt@DN@JLvBLxE\zCVbEVpFZjCR\AjAD\BHHf@Dn@DfCP|@BEr@GhAEn@Oh@[rCt@PjEx@lCb@n@JdAP”]

as per the example (omiting the departure-time as it is not required) but I keep getting a 400 Bad Request.

Has anybody any ideas on what i need to populate the Body with to get the route information.

Have you also set an Accept header to “application/vnd.ttds-route+json” and a Content-Length header as well?

If that doesn’t work do you want to give this sample https://alistairphillips.com/static/ttds.py a try and let me know how you get on.

1 Like

hi mate,
Many thanks for your python code. I managed to get my code to work by including the Accept and think I had the Body wrong too so thanks for that.
Still trying to get the API Explorer to work with the update but it keeps going back to the dashboard.
Happy enough to get it working in python though.

Thanks again

Sorry about the API Explorer bug… and has been raised with our vendor.

This works for me with the explorer: