无法使用f#和RestSharp为Mailgun验证REST Api



我尝试在f#中使用restsharp来调用Mailgun API。

我模仿了Mailgun的c#示例代码,但是我不能让它运行。

问题代码为:

let client: RestClient = 
new RestClient(
BaseUrl = Uri("https://api.mailgun.net/v3")
)

client.Authenticator = new HttpBasicAuthenticator("","") 

这个表达式的类型应该是IAuthenticator',但这里的类型是'HttpBasicAuthenticator'

似乎某人的继承类型与预期类型不同,这对我来说没有意义。HttpBasicAuthenticator对象说它继承自authentocatorBase

我还没有测试过,但很可能必须将新对象强制转换到接口。f#需要它

client.Authenticator = new HttpBasicAuthenticator("","") :> IAuthenticator

看看https://fsharpforfunandprofit.com/posts/interfaces/

最新更新