AFNetworking自动包装JSON中的请求?(AFNetworking automatically wraps requests in JSON?)

编程入门 行业动态 更新时间:2024-10-25 17:15:08
AFNetworking自动包装JSON中的请求?(AFNetworking automatically wraps requests in JSON?)

我对AFNetworking有一个小问题。

我试图用POST参数简单调用一个路径(例如http://myserver.com/index.php ,参数myParam = 1)

我已经尝试过同时使用AFURLConnectionOperation和AFJSONRequestOperation,当我输出“请求”时,它显示{“myParam”:1},好像它将我的请求打包为json,实际上它应该是常规帖子(响应是JSON,但那不太相关)。

有没有人知道如何克服这个问题,除了使用NSURLConnection?

谢谢 :) 夏嘉曦

I'm having a small problem with AFNetworking.

Im trying to have a simple call to a path with POST parameters (e.g. http://myserver.com/index.php with parameters myParam=1)

I've tried using both AFURLConnectionOperation and AFJSONRequestOperation and on both when i output the "request", it shows {"myParam":1}, as if its packing my request as json, when actually it should be regular post (the response is JSON , but thats less relevant).

Does anyone know how to overcome this issue except for using NSURLConnection ?

Thank you :)Shai

最满意答案

只需在AFHTTPClient中将parameterEncoding设置为AFFormURLParameterEncoding即可

Just set parameterEncoding to AFFormURLParameterEncoding in your AFHTTPClient

更多推荐

本文发布于:2023-07-14 23:42:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1108354.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:JSON   AFNetworking   automatically   requests   wraps

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!