Google安全浏览返回400个错误请求

时间:2014-03-28 05:29:18

标签: f# google-api f#-data safe-browsing

谷歌正在回复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请求验证了我的密钥是正确的,它只是失败的帖子。

1 个答案:

答案 0 :(得分:2)

当我将FSharp.Data更新到版本2.0.5(2014-03-29发布)时,这开始工作。我只能假设先前版本中存在一个现在已修复的错误。

release notes州:

  

已添加 - 默认缺失值列表。重新加入支持   在错误的情况下指定已知的HTTP标头。修复了HTTP的发送问题   在使用FSharp.Data的可移植类库版本时的请求   完整的.NET版本。

这是最终(工作)代码:

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字符串中的错误。