afnetworking-2

how to get return in AFHTTPRequestOperationManager request in afnetworking

a 夏天 提交于 2019-12-22 01:36:22
问题 Hi i am posting data in using AFHTTPRequestOperationManager class getting the response from server but not able to return data . method return is executed first then success data is coming i want to get the value in return . this is my code .h file @interface ServerRequest : NSObject { } -(NSString *) JsonData:(NSString *)newparams actionmethod:(NSString *)action parameters:(NSDictionary *)params; .m #import "ServerRequest.h" #import "AFNetworking.h" @implementation ServerRequest { } -

AFNetworking version 2 content-type error

有些话、适合烂在心里 提交于 2019-12-21 17:49:05
问题 I'm attempting to make an iphone app that will interact with a particular JIRA server. I've got the following code to log in: NSURL *url = [[NSURL alloc] initWithString:@"https://mycompany.atlassian.net/rest/auth/latest/session/"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; NSString *postString = [NSString stringWithFormat:@"{\"username\":\"%@\",\"password\":\"%@\"}", username, password]; [request setHTTPBody:[postString

How send request with AFNetworking 2 in strict sequential order?

送分小仙女□ 提交于 2019-12-21 16:56:34
问题 I'm doing the sync to mirror a sqlite DB to a server one. I have a Master-Detail table, where the details must be send to the server ASAP. However, is possible that detail 3 arrive before detail 2. I need to mimic the steps made to the document and respect the order of the operations. When a record is saved locally, I send a notification and then post the data. How I can guarantee a strict sequential order using AFNetworking? 回答1: By default, operations run concurrently, with no guarantee of

why is RestKit changing my response content-type?

↘锁芯ラ 提交于 2019-12-21 12:29:33
问题 In short: I try to fetch data form the server with the content-type of the http request header set as @"text/html .. but for some reason RestKit changes that to application/JSON Explanation: If I were to make this request using just AFNetworking.. things work like a charm.. this is what my AFNetworking code looks like: AFHTTPClient *client = [AFHTTPClient alloc] initWithBaseURL: [NSURL URLWithString:kApiBaseUrl]]; singleton.parameterEncoding = AFJSONParameterEncoding; [singleton

how to create simple Http request via AFNetworking

删除回忆录丶 提交于 2019-12-21 09:24:45
问题 I am still using ASIHTTPRequest and I am looking forword to move to AFNetworking i also gone through Raywenderlich Crash Course But its not using AFNetworking 2.0 I have just tried below sample which is mentioned at AFNetworking but its not working some how. AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; //manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"]; NSDictionary *parameters = @{@"UserId": @"24",@"ArticleId":@"0"};

AFHTTPSessionManager header

强颜欢笑 提交于 2019-12-21 06:06:38
问题 I am trying to set a default header for "Content-Type" by setting HTTPAdditionalHeaders. When I look at the request header, AFNetworking (v 2.0.3) changes it back. I also tried to set header by setValue:forHTTPHeaderField: on the requestSerializer, but no success. What I am missing? UPDATED NSURL *URL = [NSURL URLWithString:@"http://example.com/api"]; NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; configuration.HTTPAdditionalHeaders = @{@

multipart PUT request using AFNetworking

狂风中的少年 提交于 2019-12-21 04:19:08
问题 What's the correct way to code a multipart PUT request using AFNetworking on iOS? (still Objective-C, not Swift) I looked and seems like AFNetworking can do multipart POST but not PUT , what's the solution for that? Thanks 回答1: You can use multipartFormRequestWithMethod to create a multipart PUT request with desired data. For example, in AFNetworking v3.x: AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; NSError *error; NSURLRequest *request = [manager.requestSerializer

How to upload task in background using afnetworking

前提是你 提交于 2019-12-21 04:06:30
问题 I'm trying to upload large files using AFNetworking and have the upload continue when the application is in the background. I can upload files just fine, but when I attempt to use a background configuration -- the application crashes with the following stacktrace: Exception: EXC_BAD_ACCESS (code=1, address=0x8000001f)) _CFStreamSetDispatchQueue -[__NSCFBackgroundDataTask captureStream:] __70-[__NSCFBackgroundDataTask _onqueue_needNewBodyStream:withCompletion:]_block_invoke_2 _dispatch_call

How can I set cookies with AFNetworking 2.0 while uploading image with parameteres?

浪子不回头ぞ 提交于 2019-12-20 14:08:34
问题 What if I had to attach a cookie with a post requst? How should I do this? NSURL *URL = [NSURL URLWithString:addAddressUrl]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL]; // Set cookie too NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:[NSURL URLWithString:@"<URL>"]]; NSDictionary *cookiesDictionary = [NSHTTPCookie requestHeaderFieldsWithCookies:cookies]; if(cookiesDictionary) { [request setAllHTTPHeaderFields:cookiesDictionary]; }

AFNetworking 2.0 - use responseObject as NSDictionary

霸气de小男生 提交于 2019-12-20 10:33:09
问题 AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; [manager GET:@"http://example.com/resources.json" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"JSON: %@", responseObject); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"Error: %@", error); }]; this is the recommended way to send GET request in AFNetworking 2.0. I want to get the value of a specific key in the json, so I want to use