afnetworking 3 - Not able to parse response in JSON response -


i using afnetworking 3, xcode 7.2 ios 9.

afurlsessionmanager *ses = [[afurlsessionmanager alloc] initwithsessionconfiguration:[nsurlsessionconfiguration defaultsessionconfiguration]]; ses.responseserializer = [afjsonresponseserializer serializer];  //request [[afjsonrequestserializer serializer] setvalue:@"application/json" forhttpheaderfield:@"accept"]; nsmutableurlrequest *request = [[afjsonrequestserializer serializer] requestwithmethod:@"get" urlstring:endpoint parameters:parameters error:nil];  nsurlsessiondatatask *datatask = [ses datataskwithrequest:request completionhandler:^(nsurlresponse *response, id responseobject, nserror *error) {     if (error) {         nslog(@"error: %@", error);     } else {         nslog(@"%@ %@", response, responseobject);     } }]; [datatask resume]; 

but getting error response as:

domain=com.alamofire.error.serialization.response code=-1016 "request failed: unacceptable content-type: text/plain"

the request content type still set "text/plain" not sure missing .

i used http response serializer , worked fine.

afurlsessionmanager *ses = [[afurlsessionmanager alloc] initwithsessionconfiguration:[nsurlsessionconfiguration defaultsessionconfiguration]];     ses.responseserializer = [afhttpresponseserializer serializer];  nsmutabledictionary * innerjson = [nsjsonserialization                                                jsonobjectwithdata:responseobject options:kniloptions error:&error1]; 

Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -