Inconsistent API responses


#1

I’m getting inconsistent responses to calls made to the https://api.transport.nsw.gov.au/v1/gtfs/schedule API.

To cover off the usual first questions…
(1) Yes, I am sending an authentication key - registered with the OpenData hub and got the key to send in the header as “Authorization”, value “apikey xxxxxxxxxxxx” (so apikey, space then my api key value.
(2) Yes, I have selected the data sets to get access to

So this works;
https://api.transport.nsw.gov.au/v1/gtfs/schedule/buses/ECR109 and I get a .zip file
https://api.transport.nsw.gov.au/v1/gtfs/schedule/buses/OSMBSC012 fails and if I look at the response I get this header info:

cache-control: private content-disposition: attachment; filename=OSMBSC012_GTFS_20190106130400.zip content-type: application/octet-stream;charset=UTF-8 expires: Fri, 12 Apr 2019 14:00:00 GMT last-modified: Sun, 06 Jan 2019 13:04:55 GMT

Your API has a binary response.
Choose what to do next:

Click “View in new tab”

{ “ErrorDetails”:{ “TransactionId”:“xxxxxxxxx-yyyyyyyyy”, “ErrorDateTime”:“2019-01-11T06:41:39.442-08:00”, “Message”:“The calling application is unauthenticated.”, “RequestedUrl”:"/v1/gtfs/schedule/buses/OSMBSC012", “RequestMethod”:“GET” } }

(TransactionId value redacted)

Same happens if I click “Download”
I’m using the Swagger plug-in on Chrome.

Any thoughts / ideas ?


#2

I should add that if I do similar with the vehiclepos and set debug=true I get a valid response: https://api.transport.nsw.gov.au/v1/gtfs/vehiclepos/buses?debug=true

If I try and get the sydneytrains or nswtrains schedule (timetable) then that doesn’t work, but the ferries one does.

Very confused !


#3

Hi @andymacjones, it looks like everything is working correctly. I’m getting a 200 OK response for both of those endpoints and getting a .zip file download option for both too. I recommend using our API explorer to play around with the APIs and see how they work. I’m not really familiar with that Chrome plug-in.

Furthermore, you will get a binary response for these APIs and you need our protobuff file to convert those to plain text. You can read more about this on our troubleshooting page. If the “debug=true” parameter is available in the swagger then you have the option to see a plain text response.

If you still have issues with the API please provide more details so I can investigate further.

Thanks,
Alex


#4

I’ve just tried the example above and I get the response you get above but if I try and download the .zip or open in new tab (as it does in other examples) then I get the same error (in both download and new tab) in the Swagger UI.

{ “ErrorDetails”:{ “TransactionId”:“xxxxxxxxxxxxxxxxx-yyyyyy”, “ErrorDateTime”:“2019-01-14T00:25:51.726-08:00”, “Message”:“The calling application is unauthenticated.”, “RequestedUrl”:"/v1/gtfs/schedule/buses/OSMBSC012", “RequestMethod”:“GET” } }

I’ve not had much luck with the OpenData API previously hence using Swagger. Mainly seemed to be around what API key to use. Could you send me a screen shot/specifics about using the OpenData API UI and exactly what to put into the various fields ?

thanks,


#5

Hi @andymacjones, if you’re getting the same response then there shouldn’t be an issue. The error message you’re getting tells me that there might be something wrong with your application setup. Can you please confirm the name of the application you set up to use so I can investigate further?

Thanks,
Alex


#6

Hi @andymacjones, furthermore I tried it with your app/api key and it worked correctly. Please try again using our API explorer on this page - https://opendata.transport.nsw.gov.au/node/332/exploreapi

Just select your application from the drop down at the top then click on the endpoint you want. You shouldn’t have to change anything else, just click on “Try it out!” and you’ll get the response with the download link.

Thanks,
Alex


#7

I’ve worked out what the issue is. On the little red ! next to the Response Class (Status 200) for the Available Authorizations you select “None or other” and then need to check the “ user” box, then click [Authorize]. Then at the bottom of the HTTP error responses there’s a button that says “Try it out!” but this LOOKS to be grayed out. If you then move your mouse over it, it then goes blue and you can click it and you get a response. If you then click away from it it goes back to looking like it’s grayed out again.
So for me at least it was a bit of a UI fail. I’ve tried it on Chrome and it’s a little more obvious as the colour contrast is a little better.


#8

Thanks that’s good to know. We’ll look into changing the colour of the button to make it easier to identify.

Thanks,
Alex


#9

That’s great thank you. I’ve also been using the nicely formatted CURL text to let me generate the data that way too.