Reputation: 5187
Google is returning a 400 bad request; but what is wrong with the request?
open FSharp.Data
let apiKey = "key goes here - removed for stackoverflow"
let postUrl = "http://safebrowsing.clients.google.com/safebrowsing/downloads"
let testArray = "2\nhttp://www.google.com/\nhttp://ianfette.org/"
[<EntryPoint>]
let main argv =
let foo2 = Http.Request(postUrl, httpMethod = "Post",
query = [ "client", "api"; "apikey", apiKey; "appver", "1.0"; "pver", "2.2" ],
body = TextRequest (testArray)
)
0
I have verified that my key is correct by successfully executing get requests, it is only the post that is failing.
Upvotes: 2
Views: 961
Reputation: 5187
When I updated FSharp.Data to version 2.0.5 (released 2014-03-29) this started working. I can only assume that there was a bug in the previous version that is now fixed.
release notes state:
Added - to the list of default missing values. Re-added support for specifying known HTTP headers in the wrong case. Fixed sending of HTTP requests when using a portable class library version of FSharp.Data in the full .NET version.
Here is the final (working) code:
open FSharp.Data
let apiKey = "key goes here"
let postUrl = "https://sb-ssl.google.com/safebrowsing/api/lookup"
let testArray = "2\nhttp://www.google.com/\nhttp://ianfette.org/"
[<EntryPoint>]
let main argv =
let foo2 = Http.Request(postUrl, httpMethod = "Post",
query = [ "client", "api"; "apikey", apiKey; "appver", "1.5.2"; "pver", "3.0" ],
body = TextRequest (testArray)
)
0
Thank you to Sergey Tihon for finding the error in my URL string in the question.
Upvotes: 2