user2543991
user2543991

Reputation: 625

AFNetworking 2.0 AFHTTPSessionManager

When I use AFHTTPRequestOperationManager, I can use the HTTPRequestOperationWithRequest method with NSURLRequest object. With this object, I can configure the request object with http body in which I can put a xml file.

Now I try to use the newer AFHTTPSessionManager, I only can use the GET, POST, etc. How I can put a xml file in the http request's body? Thanks.

Upvotes: 0

Views: 432

Answers (1)

Aaron Brager
Aaron Brager

Reputation: 66242

In AFNetworking 2, a new object called the "request serializer" is how you are supposed to create your request body. There is no built-in serializer for posting XML. You'll need to subclass AFHTTPRequestSerializer, and set it as your manager's request serializer, like so:

[AFHTTPSessionManager manager].requestSerializer = [YourXMLRequestSerializer serializer];

When you subclass AFHTTPRequestSerializer, you'll need to override requestWithMethod:URLString:parameters:error: to return an NSMutableURLRequest with your desired content.

Upvotes: 3

Related Questions