AFNetworking 2.0 how to put some parameters in the query string of a POST request

南笙酒味 提交于 2019-12-24 12:33:52

问题


I need to call a ws to send an image to a server.
Who mades the webserver, decided that the session token should be sent trough the URL and not in the body.
The query should look like: http://api.service.com/imageupload.php?token=434353435 and in the body there should be the image with its parameter.
The session manager when I use the -POST methods puts all the parameter inside the body.
Is there a way to say to the request serializer to put some parameters in the query string and others in the body? or do I need to subclass it?


回答1:


This can be done like this

NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL URLWithString:[@"Google.com" stringByAppendingString:AFQueryStringFromParametersWithEncoding(parameters, NSUTF8StringEncoding)]]] ;

Where parameters is a dictionary



来源:https://stackoverflow.com/questions/24052480/afnetworking-2-0-how-to-put-some-parameters-in-the-query-string-of-a-post-reques

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!