cannot post using afnetworking

I want to log in into the following server:

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    NSDictionary *parameters = @{@"user[email]":email, @"user[password]":password, @"user[password_confirmation]":password_confirmation};
    [manager POST:@"" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSData *tocken=responseObject;
        NSLog(@"tocken is %@",tocken);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSData *errorData = error.userInfo[AFNetworkingOperationFailingURLResponseDataErrorKey];
        NSDictionary *serializedData = [NSJSONSerialization JSONObjectWithData: errorData options:kNilOptions error:nil];
        NSLog(@"traslated Error: %@", serializedData);
        NSLog(@"error: %@",error);


but I got this error:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil'

But my parameter is not empty, I check it while it is running. does any body know the reason?

Thanks a lot

Source: ios

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.