Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need help interfacing with the National Rail Enquiries (UK) API (LDBWS)

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!

like image 536
Graeme Job Avatar asked Oct 31 '22 14:10

Graeme Job


1 Answers

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

like image 148
George McDonnell Avatar answered Nov 10 '22 00:11

George McDonnell