I've registered for a token to access the National Rail (UK), Live Departure Boards API, but I can't seem to get it to work. Can anybody point out what I'm doing wrong?
I used WSDL.EXE to build a C# SOAP Proxy class, as specified here: https://realtime.nationalrail.co.uk/ldbws/
The generated .cs proxy file is 1318 lines long, but it looks correct.
My code is as follows: (LDBServiceSoap is the generated proxy class)
static void Main(string[] args)
{
LDBServiceSoap ldb = new LDBServiceSoap();
ldb.AccessTokenValue = new AccessToken() {
TokenValue = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
};
StationBoard sb = ldb.GetDepartureBoard(4, "WAT", "VIC", FilterType.from, 0, 120);
}
The Url is set inside the proxy class, so I can't think of anything else I need to do.
But when the debugger gets up to the GetDepartureBoard method, it throws a WebException "The request failed with HTTP status 401: Unauthorized."
Does anybody know what I'm missing / doing wrong here?
You're awesome!
If you obtained your access token through the OpenLDWS signup then your token will only work on the https://realtime.nationalrail.co.uk/OpenLDBWS/ endpoint that could be your problem
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With