Getting error to decode response body of timetable


#1

hello every one
i am getting this type of error

Illegal wire type of unknown field 0 in Message .transit_realtime.FeedMessage#decode: 3
my code is

var request = require(‘request’);
var GtfsRealtimeBindings = require(‘gtfs-realtime-bindings’);
var fs = require(‘fs’);

var token;
var tokenConfig = {
scope: ‘user’,
grant_type: ‘client_credentials’
};

var credentials = {
clientID: ‘##############’,
clientSecret: ‘###########’,
site: ‘https://api.transport.nsw.gov.au’,
tokenPath: ‘/auth/oauth/v2/token’,
useBasicAuthorizationHeader: true,
useBodyAuth: false
};

// Initialize the OAuth2 Library
var oauth2 = require(‘simple-oauth2’)(credentials);
oauth2.client.getToken(tokenConfig, saveToken);
function saveToken(error, result) {
console.log(“saveToken”);
if (error) {
console.log(‘Access Token Error’, error.message);
console.log(error);
} else {
token = oauth2.accessToken.create(result);
var requestSettings = {
method: ‘GET’,
url:‘https://api.transport.nsw.gov.au/v1/publictransport/timetables/complete/transxchange’,
encoding: null,
‘auth’: {
‘bearer’: token.token.access_token
}
};
console.log(requestSettings);
request.get(requestSettings, function(err, res, body) {
var feed = GtfsRealtimeBindings.FeedMessage.decode(body);
feed.entity.forEach(function(entity) {
if (entity) {
// console.log("’" + entity.vehicle.vehicle.label + “’,” + entity.vehicle.position.latitude + “,” + entity.vehicle.position.longitude);
console.log(entity);
}
});
})
}
};
please help me


#2

Hi dhamu143, We are looking into it, will keep you update


#3

Morning,
I get the same error when I try.
However I think I may have found the problem.

Static timetables and stop locations in TransXChange (TXC) format for all operators, including regional and private operators and routes not currently available in realtime feeds. Note: Identifiers do not match the realtime APIs

If I download using curl and save the output to a zip file and then unzip the file I get a lot of xml files.
i.e

curl -H"Authorization: Bearer xxxxx-xxxxx-xxxxx-xxxxx-xxxxx" https://api.transport.nsw.gov.au/v1/publictransport/timetables/complete/transxchange -o transxchange.zip unzip -l transxchange.zip

Hope that helps.


#4

Hi Dharmu143

The data from this URL https://api.transport.nsw.gov.au/v1/publictransport/timetables/complete/transxchange is in TransXChange format. The format your code seems to be expecting is in GTFS format per your declaration var GtfsRealtimeBindings = require(‘gtfs-realtime-bindings’);

The formats don’t match. You may need to use the schedule data for Realtime instead.

More details about TransXChange can be reviewed here https://www.gov.uk/government/collections/transxchange

You will also note Nivring’s comments about using TransXChange data.


#5

if we use this URL https://api.transport.nsw.gov.au/v1/publictransport/timetables/complete/gtfs and URL https://api.transport.nsw.gov.au/v1/gtfs/schedule/buses instead of using transxchange data then
it also gives same error.
now what to do ?


#6

Unfortunately there is currently an issue that should be resolved shortly… where we don’t have the scheduled data that you need.

Refer to this thread for more information and updates:
http://opendata.transport.nsw.gov.au/forum/t/gtfs-bundle-for-type-schedule-is-not-available-for-agency-buses/65