I'm trying to get some html from a page hosting by IIS where Windows authentication is enabled.
So far I have:
open FSharp.Data
[<EntryPoint>]
let main argv =
let html = Http.RequestString ("http://mywebsite.com/Detail.aspx", query=[("zip","9000");("date","11/01/2017")], headers=[???])
printf "%s" html
System.Console.ReadLine() |> ignore
0 // return an integer exit code
What do I need to add in the headers list?
I'd agree with Anton that if you need further customization, then using the raw .NET API for making the request might be easier. That said, the RequestString does have a parameter customizeHttpRequest which lets you specify a function that sets other properties of the request before it is sent, so you can use the following to set the Credentials property:
open System.Net
let html =
Http.RequestString("http://mywebsite.com/Detail.aspx",
query=[("zip","9000");("date","11/01/2017")],
customizeHttpRequest = fun r ->
r.Credentials <- new NetworkCredential( "username", "password", "domain" )
r)
For more information about what properties to configure, have a look at the .NET question that Anton mentioned in a comment.
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