Search code examples
iosnsarrayafnetworking

Right way to pass NSArray of NSNumber as parameter in AFNetworking


I am trying to send in POST request AFNetworking this package:

NSDictionary*parameters = [NSDictionary dictionaryWithObjectsAndKeys:[NSArray arrayWithObjects:@719,@714, nil],@"rules", nil];

[manager POST:path parameters:parameters success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        triedAuthorize = NO;

    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

    }];

And server returns error as if I made error in JSON

In this case server returns success:

NSDictionary*parameters = @{@"rules":@"[719,714]"}

and this is successful to

NSDictionary*parameters = @{@"rules":@"719,714"}

Solution

  • I've solved this

    Problem was not in array as parameter. I've added this and everything work:

    manager.requestSerializer = [ALFJSONRequestSerializer serializer];