I’ve found that the response from the above endpoint randomly sometimes returns XML and other times is JSON.
I’m setting the content-type http header to application/json
I’ve created the same request in Postman and it exhibits this switching between xml and json - and also simply opening that endpoint in a browser and then refreshing multiple times will yield the same behaviour.
Ah yes I meant “use curl” when I was meaning the simplest way of using the interface. Browsers aren’t never good test environments, you have no idea what’s going on unless you press F12 and look at the Network tab and then the Headers tab…
I tried using plain CURL as you suggest - same behaviour. One execution returns maybe XML and then on the next execution JSON. The screenshot shows the output from running once - you can see the end of the result is XML. Then I run exactly the same command again - you can see it’s JSON.
(The screenshot is a little hard to ready - sorry !)
Using cURL vs a browser here should make absolutely no difference - it’s the API endpoint that’s broken, as the Unified API should only ever return JSON data, not XML (even if requested directly through the browser). Especially given it keeps switching between the 2 - if it was the browser’s fault, it’d be more likely to just always return XML.
Rather odd that /line/mode/{modes}/status has this issue, but /line/{lines}/status doesn’t.
Hi - we’re still looking into the issue, but you should be able to get a consistent JSON response if you pass the Accept header as application/json (or text/xml for XML)
So I’ve tried previously (and just now) with the “Accept” header set to application/json - that’s what I thought was the problem initially. However - even with the header set it still randomly returns either XML or JSON.
Is there a round-robin effect here - where one server is returning XML but the others are returning JSON ?
Thanks @itcombox - that’s good to know. We do have a caching/logic layer as well as a load-balanced layer of webservers.
We’re still trying to identify where this issue is occurring - we hadn’t been able to recreate what you have done there when specifying application/json though.
Hi @jonathanbeaumont - we put in a solution to deal with the errant caching back in 2022. Apologies if I’m missing something but I can’t see any data differences between the JSON and XML that you have posted there.
Today i’m getting the same on https://api.tfl.gov.uk/Line/victoria/Status - i’ve set an Accept header to application/json but i keep getting back XML replies for this query
Hi @robal - we’ve now switched to another environment while we look at what was happening here. Can you please let us know if you have any further issues with this.
Many thanks,
James