title: Unable to send Multipart-Form data with AFNetworking 3.0
body: <p>Currently, I've trying to write a method in Objective C that takes in a UIImage and a NSString and makes a POST request to a server. Unfortunately, I have trouble getting it to send anything. When I tried the form with an HTML form, I was able to successfully upload a photo and the parameters. However, I am unable to replicate it in my iOS app. I keep getting a 404 error when I try to make a POST request.</p>
  
  <p>I've tried two different methods of sending a multiform data POST request according to its Github page to no success. I've debugged the UIImage in Xcode and I see that it actually exists. I'm thinking it has something to do with the parameters I'm sending. Should the parameters be part of formDataAppend or just as a dictionary as I did below?</p>
  
  <p>The commented part corresponds with the tutorial on its Github. The uncommented section contains parts from browsing Stackoverflow still to no avail.</p>
  
  <pre><code>+(void) uploadPhotoWithID:(NSString *)ownerID andPhotoImage:(UIImage *)image andCompletionHandler:(void (^)(MZPhoto *, NSError *))callback{
  
      NSData *imageData = UIImageJPEGRepresentation(image, 1);
      NSDictionary *parameters = @{@"owner_id": ownerID};
  
  //    NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:upload_photo_url parameters:parameters constructingBodyWithBlock:^(id&lt;AFMultipartFormData&gt;  _Nonnull formData) {
  //        [formData appendPartWithFileData:imageData name:@"photo" fileName:@"temp.jpg" mimeType:@"image/jpeg"];
  //    } error:nil];
  //    AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
  //    
  //    NSURLSessionUploadTask *uploadTask  = [manager uploadTaskWithStreamedRequest:request progress:nil completionHandler:^(NSURLResponse * _Nonnull response, id  _Nullable responseObject, NSError * _Nullable error) {
  //        if(error){
  //            NSLog(@"File Upload Failed");
  //            
  //        }
  //        else{
  //            NSLog(@" %@", responseObject);
  //            MZPhoto *photo = [[MZPhoto alloc] initWithDictionary:responseObject error:nil];
  //            callback(photo, nil);
  //        }
  //    }];
      AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithBaseURL:[NSURL URLWithString:upload_photo_url]];
      [manager POST:upload_photo_url parameters:parameters constructingBodyWithBlock:^(id&lt;AFMultipartFormData&gt;  _Nonnull formData) {
          [formData appendPartWithFileData:imageData name:@"photo" fileName:@"photo.jpg" mimeType:@"image/jpeg"];
      } progress:nil
            success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
                NSLog(@" %@", responseObject);
            } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
                NSLog(@" Failed");
            }];
  
  
  
  }
  </code></pre>
  
  <p>Here is my Node.JS function,</p>
  
  <pre><code>exports.upload_photo = function(req, res, next) {
      var owner_id = req.body.owner_id;
      console.log(owner_id);
      pg.connect(connectionString, function(err, client, done) {
          if (err) {
              done();
              console.log(err);
              return res.status(500).json({success: false, data: err});
          }
  
          var query = client.query("INSERT INTO photos (likes, dislikes, user_id) " +
                                      "VALUES (0, 0, $1) RETURNING photo_id, likes, dislikes, user_id", [owner_id]);
          var result;
          console.log(req.file);
  
          query.on('row', function(row) {
              row.file_url =  baseFileURL + row.photo_id + '.jpg';
              result = row;
          });
  
          query.on('end', function() {
              done();
              fs.rename('./static/photos/' + req.file.filename, './static/photos/' + result.photo_id + '.jpg', function(err) {
                  if(err) console.log("Error Renaming the file!");
                  return res.json(result);
              });
          });
      });
      console.log("Received photo upload from: " + owner_id);
  }
  </code></pre>