3

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?

1
  • Have you considered standard .NET web request building? See for example this page with details about Windows authentication. Commented Jan 11, 2017 at 13:16

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

1 Comment

customizeHttpRequest = fun r -> r.UseDefaultCredentials <- true r did the trick, thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.