0

I need to make HTTP POST request, in that request I have to send some text fields and couple of files. Every time I make the request, the files are uploaded, but I get such response. "Success: <656d7074 79>" (aka "empty")

Here is the code, my parameter dictionaries are .

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
manager.requestSerializer = [AFHTTPRequestSerializer serializer];
AFHTTPRequestOperation *operation = [manager POST:url parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
    // Append Files
    NSError *error;
    for (NSString *filePathsKey in filesPathsDictionary) {
        [formData appendPartWithFileURL:[NSURL fileURLWithPath:filesPathsDictionary[filePathsKey]] name:filePathsKey error:&error];
        if (error) {
            NSLog(@"%@", error);
        }
    }

    // Text parameters
    for (NSString *textParameterKey in textParamDictionary) {
        [formData appendPartWithFormData:[textParamDictionary[textParameterKey] dataUsingEncoding:NSUTF8StringEncoding] name:textParameterKey];
    }

} success:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog(@"Success: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Error: %@", error);
}];

[operation start];

UPDATE: Changed my response serializer to JSON, because I'm expecting JSON manager.responseSerializer = [AFJSONResponseSerializer serializer]; manager.responseSerializer.acceptableContentTypes = [manager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];

And getting this error: Error: Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}

0 Answers0