AFNetworking - How can I PUT and POST raw data without using a key value pair?

后端 未结 6 1001
执念已碎
执念已碎 2020-12-15 22:20

I am trying to make an HTTP PUT request using AFNetworking to create an attachment in a CouchDB server. The server expects a base64 encoded string in the HTTP b

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-15 23:18

     NSData *data = someData;
     NSMutableURLRequest *requeust = [NSMutableURLRequest requestWithURL:          
     [NSURL URLWithString:[self getURLWith:urlService]]];
    
    [reqeust setHTTPMethod:@"PUT"];
    [reqeust setHTTPBody:data];
    [reqeust setValue:@"application/raw" forHTTPHeaderField:@"Content-Type"];
    
    NSURLSessionDataTask *task = [manager uploadTaskWithRequest:requeust fromData:nil progress:^(NSProgress * _Nonnull uploadProgress) {
    
    } completionHandler:^(NSURLResponse * _Nonnull response, id  _Nullable responseObject, NSError * _Nullable error) {
    
    }];
    [task resume];
    

提交回复
热议问题