Skip to content

Instantly share code, notes, and snippets.

@EkkoG
Created May 3, 2017 06:17
Show Gist options
  • Save EkkoG/4ef8fa19309afdcd95c87b779ee4dbd8 to your computer and use it in GitHub Desktop.
Save EkkoG/4ef8fa19309afdcd95c87b779ee4dbd8 to your computer and use it in GitHub Desktop.
Custom http body use af 3.x
NSMutableURLRequest *req = [[AFHTTPRequestSerializer serializer] requestWithMethod:@"POST" URLString:@"https://example.com" parameters:@{} error:nil];
NSString *body = @"...";
req.HTTPBody = [body dataUsingEncoding:NSUTF8StringEncoding];
AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:configuration];
NSURLSessionDataTask *task = [manager dataTaskWithRequest:req completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) {
}];
[task resume];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment