How to use HTTP Basic Authentication for requests in JsonProvider and enter types without sample file?

This is a n00b question, but I was thinking about trying a new library FSharp.Data 2.0.0-alpha6for the project that I have. In particular, I am trying to read JSON messages from a web service protected by basic HTTP authentication (username and password).

How can I go with JsonProvider(or any other provider) to read documents from a URL that is authorized by authorization, in this particular case using basic HTTP authentication?

Judging by the following SO questions, it looks like I should download the sample file separately:

But then after reading Gustavo ’s comment on F # News: Downloading stock prices gives hope that it will be possible.

Even if I had to download the sample file separately, how would I use JsonProviderto parse documents from resources that require basic HTTP authentication?

My minimum working sample

open System
open FSharp.Data
open FSharp.Data.JsonExtensions

//The URLs are something like the following.
//https://xyz.com/rest/v1/datanodes?limit=20&expand=name,processData.v,processData.ts$format=json

//This one tells in a tooltip it cannot read sample from the address
//as server respons with an error 401 Unauthorized.
type x1 = JsonProvider<"https://xyz.com/rest/v1/datanodes?&format=json">

[<EntryPoint>]
let main argv = 

    //This is just of type object, probably because connection can't be made?
    let x2 = new JsonProvider<"https://xyz.com/rest/v1/datanodes?&format=json">

    0
+3
source share
1 answer

It is not currently supported, but it should not be too difficult to implement, we accept download requests. See https://github.com/fsharp/FSharp.Data/issues/158

+4
source

All Articles