httpBody [任何] to alamofire

时间:2019-02-14 19:52:46

标签: swift xcode alamofire

我需要将请求正文设置为类似的内容

 let param =  [[["user_id", "=", 31]]]

问题在于alamofire的主体就像[string:Any] 如何将对象[Any]发送到httpBody

我无法发送json,因为只有请求接受的是表单数据(如图片展示) enter image description here

当我像这样添加json raw

{“ domain”:[“ user_id”,“ =”,31]}

我遇到错误

   {
"jsonrpc": "2.0",
"id": null,
"error": {
    "code": 200,
    "message": "Odoo Server Error",
    "data": {
        "name": "werkzeug.exceptions.BadRequest",
        "debug": "Traceback (most recent call last):\n  File \"/data/som.dev.arkeup.com/server/odoo/http.py\", line 646, in _handle_exception\n    return super(JsonRequest, self)._handle_exception(exception)\n  File \"/data/som.dev.arkeup.com/server/odoo/http.py\", line 307, in _handle_exception\n    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])\n  File \"/data/som.dev.arkeup.com/server/odoo/tools/pycompat.py\", line 87, in reraise\n    raise value\n  File \"/data/som.dev.arkeup.com/server/odoo/http.py\", line 683, in dispatch\n    result = self._call_function(**self.params)\n  File \"/data/som.dev.arkeup.com/server/odoo/http.py\", line 315, in _call_function\n    raise werkzeug.exceptions.BadRequest(msg % params)\nwerkzeug.exceptions.BadRequest: 400: Bad Request\n",
        "message": "",
        "arguments": [],
        "exception_type": "internal_error"
    }
}
}

__________________编辑

我认为,如果我输入此字符串,它将可以正常工作[[[[“ user_id”,“ =”,31]]]

但是我该如何通过[任何]?去身体?

_____ EDIT

这是我的ios代码         让methodName = HTTPMethod.get           let标头= [“ Content-Type”:“ application / x-www-form-urlencoded”,“ Accept-Encoding”:“ application / json”,“ accept”:“ text / html,application / xhtml + xml,application /xml;q=0.9,image/webp,image/apng, / ; q = 0.8“]

   let data = ["domain":[[["user_id", "=", 31]]]]

    manager.request(urlS!, method: methodName, parameters: data, encoding: URLEncoding.default, headers: headers)//.responseJSON{response in
       .responseString(encoding: String.Encoding.utf8) { (response) -> Void in


            switch (response.result)
            {
            case .success:




                }

感谢您的回复

0 个答案:

没有答案