I followed the suggested solution at AFNetworking 2.0 add headers to GET request to specify custom headers for the request with the following code snippet:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
[manager.requestSerializer setValue:someID forHTTPHeaderField:@"some_id"];
NSDictionary *parameters = @{@"id": user.id, @"birthday": user.birthday};
[manager POST:[NSString stringWithFormat:@"%@/user_create",BaseURLString] parameters:parameters
success:^(AFHTTPRequestOperation *operation, id responseObject)
{
if (responseObject[@"error"])
{
NSLog(@"REST User Create Response Error: %@", responseObject[@"error"]);
}
else
{
[self saveUserDetails:responseObject];
}
}
failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
NSLog(@"REST User Create Error: %@", error);
}];
But what happens when this gets executed is I get an error in the response from the API stating all my parameters are missing. This same block of code used to work before (without setting the custom header and when the API didn't require them originally).
Does anybody know how to properly set both custom headers and POST parameters?
Thanks, Nino