Google 返回 400 错误请求;但是这个请求有什么问题吗?
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
我已经通过成功执行 get 请求验证了我的 key 是正确的,只是失败了。
最佳答案
当我将 FSharp.Data 更新到版本 2.0.5(2014-03-29 发布)时,它开始工作。我只能假设以前的版本中存在一个错误,现已修复。
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.
这是最终(工作)代码:
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
感谢 Sergey Tihon 在问题中发现我的 URL 字符串中的错误。
关于f# - Google 安全浏览返回 400 错误请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22704890/