尝试使用 Restkit 进行多部分表单请求,但出现 NSdictionary 错误?我不确定为什么会收到此错误。
[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: 尝试从 objects[1] 插入 nil 对象'
NSMutableURLRequest *request = [[RKObjectManager sharedManager] multipartFormRequestWithObject:obj
method:RKRequestMethodPOST path:@"v1/things/update_avatar.json"
parameters:@{
@"auth_token" : self.accessToken,
@"email" : user.userID,
@"api_key" : self.api_key,
@"avatar" : @"userAvatar"
}
constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileData:UIImageJPEGRepresentation(image, 1)
name:@"obj[image]"
fileName:@"userAvatar.jpeg"
mimeType:@"image/jpeg"];
}];
RKObjectRequestOperation *operation = [[RKObjectManager sharedManager] objectRequestOperationWithRequest:request
success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
//
DLog(@"");
} failure:^(RKObjectRequestOperation *operation, NSError *error) {
//
DLog(@"");
}];
[[RKObjectManager sharedManager] enqueueObjectRequestOperation:operation]; // NOTE: Must be enqueued rather than started