Reputation: 1025
I'm just getting started in F# and was exploring FSharp.Data. I'm trying to use a web service from www.ncdc.noaa.gov. The first problem is ncdc wants a token in the request. I attempted to work around that with the following:
let apiUrl = "http://www.ncdc.noaa.gov/cdo-web/api/v2/data?datasetid=GHCND&locationid=ZIP:28801&startdate=2010-04-01&enddate=2010-04-01"
let aRequestString =
Http.RequestString(
apiUrl,
httpMethod="GET",
headers = [ "token", "mytoken"])
let sf = WeatherData.Load(aRequestString)
This seems to work - fiddler says I get a result that looks good to me and JSONLint, but I get "Illegal characters in path." from the provider.
The stack trace shows:
System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
System.IO.Path.Combine(String path1, String path2)
FSharp.Data.Runtime.IO.UriResolver.Resolve(Uri uri)
FSharp.Data.Runtime.IO.asyncRead(FSharpOption`1 _tp, UriResolver uriResolver, String formatName, String encodingStr, Uri uri)
[email protected](Uri uri)
Upvotes: 1
Views: 337
Reputation: 243051
The Load
method takes a URL or a file path and it loads data from there. If you're downloading the data on your own, you need to use the Parse
method instead.
let apiUrl = "http://www.ncdc.noaa.gov/cdo-web/api/v2/data?datasetid=...."
let aRequestString =
Http.RequestString(
apiUrl,
httpMethod="GET",
headers = [ "token", "mytoken"])
let sf = WeatherData.Parse(aRequestString)
// ^^^^^
Upvotes: 3