FSharp.Data Http.RequestString doesn't work obtaining repositories via GitHub API
Closed this issue · 1 comments
persiyanov commented
let FSHARP_REPOS_QUERY_STRING = @"https://api.github.com/search/repositories"
let reposJson = Http.RequestString(FSHARP_REPOS_QUERY_STRING,
query = [("q", "language:F%23")],
headers = [("Accept", "application/vnd.github.drax-preview+json")])
Выдает:
System.Net.WebException: Сервер нарушил протокол. Section=ResponseStatusLine
в System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
в <StartupCode$FSharp-Core>.$Control.callback@1717.Invoke(IAsyncResult ar)
at Microsoft.FSharp.Control.AsyncBuilderImpl.commit[a](Result`1 res)
at Microsoft.FSharp.Control.CancellationTokenOps.RunSynchronously[a](CancellationToken token, FSharpAsync`1 computation, FSharpOption`1 timeout)
at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T](FSharpAsync`1 computation, FSharpOption`1 timeout, FSharpOption`1 cancellationToken)
at <StartupCode$FSI_0027>.$FSI_0027.main@() in C:\_drack\F# Course MIPT\FSharpLicensesGithub\FSharpLicensesGithub\Program.fsx:line 17
Stopped due to error
Но, делая запрос через, скажем, hurl.it, все ок.
persiyanov commented
Добавил User-Agent и ок.
let FSHARP_REPOS_QUERY_STRING = @"https://api.github.com/search/repositories"
let reposJson = Http.Request(FSHARP_REPOS_QUERY_STRING,
query = [("q", "language%3AF%23")],
headers = [("Accept", "application/vnd.github.drax-preview+json"); ("User-Agent", "Foo")])