upload image with multipart/form-data objective C
<p>I'm new iOS developer. I want upload image with multipart/form-data, this is my obj C code, I get it from postman. And the picture are request parameters of API. I test in postman It work fine, but I test in mobile It's not working and get HTTP 500 error, please check it for me. thanks all. <a href="http://i.stack.imgur.com/LpmbM.png" rel="nofollow">picture API request parameters</a></p>

<pre><code>strURL = [NSString stringWithFormat:@"%@%@",URL,strURL];
NSArray *parameters = @[ @{ @"name": @"imageInfo", @"value": @"{\"user\":{\"userId\":\"165\"},\"description\":\"test description\",\"competitionId\":\"1\",\"speciesId\":\"13\",\"lng\":\"107.9296875\",\"lat\":\"15.83453574122155\",\"locationName\":\"Đại Lãnh, Đại Lộc, Quảng Nam, Vietnam\",\"originalImageName\":\"\"}" },
                     @{ @"name": @"filenames", @"value": @"{}" },
                     @{ @"name": @"files", @"fileName": (UIImageJPEGRepresentation(uploadImage, 0.1)) } ];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:strURL] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:10.0];
NSString *boundary = @"---011000010111000001101001";
NSDictionary *headers = @{ @"content-type": @"multipart/form-data; boundary=---011000010111000001101001",
                           @"cache-control": @"no-cache",
                           @"postman-token": @"463bcf06-08f6-7611-c1fb-13b0dde79c5c"};

NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
    [body appendFormat:@"\r\n--%@\r\n", boundary];
    if (param[@"fileName"]) {
        [body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], @"yourimage.jpg"];
        [body appendFormat:@"Content-Type: image/jpeg\r\n\r\n"];
        [body appendFormat:@"%@", param[@"fileName"]];
        if (error) {
            NSLog(@"%@", error);
        }
    } else {
        [body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
        [body appendFormat:@"%@", param[@"value"]];
    }
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLResponse *response;

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
                                            completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                                                if (error) {
                                                    NSLog(@"%@", error);
                                                } else {
                                                    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
                                                    NSLog(@"%@", httpResponse);
                                                }
                                            }];
[dataTask resume];
</code></pre>