I have not created an account, so I could not try this - but if the error message says "user agent is a required field", then I guess that the service requires setting the User-Agent
header of the HTTP request.
This is not supported in static parameters of the JsonProvider
, so the best way to get this to work would be to download the sample JSON, save it to a local file (say yp.json
) and then use that to create the type provider:
type Yp = JsonProvider<"yp.json">
To actually download some data (when you want to make a request), you can use Http.RequestString
which takes headers
- there you can specify any required headers including User-Agent
:
let response =
Http.RequestString("http://httpbin.org/user-agent", headers=["user-agent", "test"])
Then you can load the data using Yp.Parse(response)
(rather than using the Load
method directly to request a URL which would not let you specify the header).