ios - Posting JSON data using AFNetworking 2.0 -
i have web script accepts json string input through http post request. have came across several afnetworking 1.x example same , can please point me or give afnetworking 2.0 example http post request web script formatted json input ?
thanks
after searching docs , trying out codes got following example
afhttprequestoperationmanager *manager = [afhttprequestoperationmanager manager]; manager.requestserializer = [afjsonrequestserializer serializer]; nsdictionary *params = @ {@"user" :txtusername, @"pwd" :txtpwd }; [manager post:url_signin parameters:params success:^(afhttprequestoperation *operation, id responseobject) { nslog(@"json: %@", responseobject); } failure: ^(afhttprequestoperation *operation, nserror *error) { nslog(@"error: %@", error); }];
also don't forget set response header type in server script application/json.
Comments
Post a Comment