5

I'm making an authenticated request like this:

let url = "https://datafeeds.networkrail.co.uk/ntrod/CifFileAuthenticate?type=CIF_ALL_FULL_DAILY&day=toc-full"
let auth = "Basic " + (username + ":" + password |> Encoding.UTF8.GetBytes |> Convert.ToBase64String)
Http.Request(url, headers=["Authorization", auth])

Http.Request is from FSharp.Data

On a compiled F# application it works fine, but when running this on F# interactive, somehow the request sent is slightly different and I get this error:

System.Net.WebException: The remote server returned an error: (403) Forbidden.
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>

Looking under fiddler, that url returns a 302 that redirects to https://nr-datafeed-cif.s3.amazonaws.com/CIF_ALL_FULL_DAILY%2Ftoc-full.json?...

But under fsi, the subsequent requests goes to https://nr-datafeed-cif.s3.amazonaws.com/CIF_ALL_FULL_DAILY/toc-full.json?... instead.

Gustavo Guerra
  • 5,319
  • 24
  • 42
  • It might help to know what version of .NET you are targeting in your compiled app, and the FSI version too. (seems like this could be a regression issue between framework versions). – Stephen Swensen Apr 08 '13 at 15:26
  • I'm targeting .NET 4.5. FSI is running against the same version on the same machine, and this happens both with the 32 and AnyCPU versions of FSI – Gustavo Guerra Apr 08 '13 at 15:31
  • Under fiddler, can you compare your requests? – Dmitry Sevastianov Aug 30 '13 at 18:23
  • 1
    I was curious about this, so registered with Network Rail to be able to access the feeds, and my user is "Pending" awaiting sufficient capacity on the system; LOL! – Danny Tuppeny Oct 27 '13 at 16:09
  • 1
    Even now my account is active; I can't make this work at all - always get a 401 Unauthorised response :( Tried sending both username/password and username/security code that was emailed to me! – Danny Tuppeny Oct 27 '13 at 17:04

0 Answers0