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

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -