Question

I'm trying to iterate through the list of Freebase countries as follows:

#r @"..\packages\FSharp.Data.1.1.4\lib\net40\FSharp.Data.dll"

open FSharp.Data

FreebaseData.GetDataContext().``Time and Space``.Location.Countries
|> Seq.iter (fun c -> printfn "%s" c.Name)

Executing this in F# Interactive gives me the following error:

System.Net.WebException: The remote server returned an error: (400) Bad Request.
{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "badRequest",
    "message": "Unique query may have at most one result. Got 2",
    "locationType": "other",
    "location": "/location/country/iso_alpha_3"
   }
  ],
  "code": 400,
  "message": "Unique query may have at most one result. Got 2"
 }
}

Is there anything I can do to work around this problem?

Thanks, -- Rob

Was it helpful?

Solution

This is due to a bug in the Freebase type provider - see here. Based on the description of the issue there, you might be able to try something like this as a workaround:

let countries = query {
    for country in freebase.``Time and Space``.Location.Countries do
    where (country.Name <> "Ghana")
}

countries
|> Seq.iter (fun c -> printfn "%s" c.Name)

OTHER TIPS

This was fixed in FSharp.Data 1.1.5

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top