PUT 请求

NSURL *url = [NSURL URLWithString:@"你要请求的URL"];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];

request.HTTPMethod = @"PUT";

request.allHTTPHeaderFields = @{@"":@""}//此处为请求头,类型为字典

NSString *msg = @"请求参数";

NSData *data = [msg dataUsingEncoding:NSUTF8StringEncoding];

request.HTTPBody = data;

[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {

NSLog(@"%@",[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);

}] resume];

你可能感兴趣的:(PUT 请求)