Add your desired content types to AFHTTPRequestOperation
using addAcceptableContentTypes:
:
[AFJSONRequestOperation addAcceptableContentTypes:[NSSet setWithObject:@"application/vnd.com.test.v1+json"];
Vra
I have a server that is sending back JSON using the following accept header:
[self setDefaultHeader:@"Accept" value:@"application/vnd.com.test.v1+json"];
In the success block of the API calls, the response data is coming back as a NSData
object.
I read in the following question Issue with retrieving JSON with AFNetworking that I need to set @"application/json"
if I want JSON to be parsed into an NSDictionary
automatically, otherwise I have to manually do it for each call using NSJSONSerialization
.
Is there a way that I can get @"application/vnd.com.test.v1+json"
to be recognized as JSON and automatically do JSON deserialization for each request?
Oplossing
Add your desired content types to AFHTTPRequestOperation
using addAcceptableContentTypes:
:
[AFJSONRequestOperation addAcceptableContentTypes:[NSSet setWithObject:@"application/vnd.com.test.v1+json"];