iOS AFNetworking AFHTTPRequestOperationManager not setting json headers? -


im using afnetworking

pod 'afnetworking', '~> 2.2'

i need send post json headers, going out as

"content-type" = "text/html";

why??, please see in code im setting this?

- (void)postrequestwithparams:(nsdictionary*)paramasdicto andurl:(nsstring*)url                       success:(void (^)(id responseobject))success                       failure:(void (^)(nserror *error))failure {     afhttprequestoperationmanager *manager = [afhttprequestoperationmanager manager];      manager.responseserializer = [afjsonresponseserializer serializer];     manager.responseserializer.acceptablecontenttypes = [nsset setwithobject:@"application/json"];      manager.requestserializer = [afjsonrequestserializer serializer];     [manager.requestserializer setvalue:@"application/json" forhttpheaderfield:@"content-type"];      [manager      post:url      parameters:paramasdicto      constructingbodywithblock:^(id<afmultipartformdata> formdata) {       } success:^(afhttprequestoperation *operation, id responseobject) {          success(responseobject);      } failure:^(afhttprequestoperation *operation, nserror *error) {          failure(error);          dlog(@"error : %@", error);      }]; } 

please note if do: po manager.requestserializer.httprequestheaders

i get

{     "accept-language" = "en;q=1, fr;q=0.9, de;q=0.8, zh-hans;q=0.7, zh-hant;q=0.6, ja;q=0.5";     "content-type" = "application/json";     "user-agent" = "orderingshopphone/1.0 (iphone simulator; ios 7.1; scale/2.00)"; } 

nothing in the relevant afnetworking code possibly set text/html.

possible explanations:

  • you're changing somewhere else in code before goes out
  • you have intermediary server that's changing request after leaves app (for example, load balancer might overwriting it).

side note: there have been lots of important bug fixes since version 2.2; should update 2.3.1, although don't think it'll fix issue.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -