Alamofire Put Request什么都不返回

时间:2017-04-29 16:08:18

标签: ios json swift alamofire

我试图更新mLab中的值。我可以成功插入和获取数据但我无法更新它。下面的代码返回HTTP 415错误。但数据库没有任何反应。我试图修复它直到几周但没有任何反应。

  let parameters_post: Parameters = [ "q" : "{\"uname\":\"e\"}",
        "$set": "{\"uname\":\"emree\"}",
        ]
    Alamofire.request("https://api.mlab.com/api/1/databases/mysignal/collections/Cusers?apiKey=myApiKey", method: .post, parameters: parameters_post,encoding: URLEncoding.default, headers: nil).responseJSON{ response in
        print(response.result)
        print(response.request)
        print(response.response)

    }
}

这是API文档

    PUT /databases/{database}/collections/{collection}
Content-Type: application/json
Body: <JSON data>

Example setting "x" to 3 in the document with "_id" = 1234 (using jQuery):

$.ajax( { url: 'https://api.mlab.com/api/1/databases/my-db/collections/my-coll?apiKey=myAPIKey&q={"_id":1234}',
          data: JSON.stringify( { "$set" : { "x" : 3 } } ),
          type: "PUT",
          contentType: "application/json" } );

Optional parameters:
[q=<query>][&m=true][&u=true]

0 个答案:

没有答案