问题
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