I have an error on the server while uploading a video using NSURLSessionUploadTask, the server error states:
PHP Warning: Missing boundary in multipart/form-data POST data in Unknown on line 0
and here is my code:
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];
NSString *finalURLFormat = [NSString stringWithFormat:@"%@%@", kAPIUrl, url];
NSMutableURLRequest *request = [self setHeadersForURL:finalURLFormat Method:@"POST"];
[request setHTTPMethod:@"POST"];
NSURLSessionUploadTask *postDataTask = [session uploadTaskWithRequest:request fromFile:data completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
NSError *jsonError;
NSDictionary *jsonResponse =
[NSJSONSerialization JSONObjectWithData:data
options:NSJSONReadingAllowFragments
error:&jsonError];
if (!jsonError) {
NSHTTPURLResponse *httpResp = (NSHTTPURLResponse*) response;
if (httpResp.statusCode < 400) {
}
else {
}
}
}];
[postDataTask resume];