5

我正在发出这样的经过身份验证的请求:

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 来自FSharp.Data

在已编译的 F# 应用程序上它工作正常,但是在 F# 交互式运行它时,发送的请求以某种方式略有不同,我收到此错误:

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>

在提琴手下查看,该网址返回一个 302 重定向到https://nr-datafeed-cif.s3.amazonaws.com/CIF_ALL_FULL_DAILY%2Ftoc-full.json?...

但是在 fsi 下,后续请求会转到https://nr-datafeed-cif.s3.amazonaws.com/CIF_ALL_FULL_DAILY/toc-full.json ?... 。

4

0 回答 0