Example on using AFNetworking to post XML?

不羁的心 提交于 2019-12-11 01:19:02

问题


As a followup to this question, I cannot get this to work so I need to take a step back I think.

Can someone post some sample code on how to post XML to a rest service WITHOUT using params? Is it even possible? Basically I have an object with several properties, and I convert this to XML and then need to upload it. But it fails if there is an image converted to string in the XML. Without that it works fine.

Even a JSON example would be helpful...

Totally blocked here :P


回答1:


Use NSMutableURLRequest -setHTTPBody:, and set the Content-Type HTTP header to application/xml.

If you're doing this consistently, you may want to consider subclassing AFHTTPClient to add an XML parameter serialization option.



来源:https://stackoverflow.com/questions/10764166/example-on-using-afnetworking-to-post-xml

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