AFNetworking 2.0 Send Post Request with URL Parameters

后端 未结 6 2135
忘掉有多难
忘掉有多难 2020-12-19 05:16

How do I send a POST request with AFNetworking 2.0 with all the parameters in the URL like such:

http://www.myserver.com?api_key=something&

6条回答
  •  隐瞒了意图╮
    2020-12-19 06:04

    can you try this.

    NSString* apiURL = @"http://example.com" 
    AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:[NSURL URLWithString:apiURL]];
    manager.responseSerializer = [AFJSONResponseSerializer serilizer];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"application/json"];
    
    NSDictionary *parameters = @{@"name":@"John",@"date":"27/12/2013"};
    
    AFHTTPRequestOperation *apiRequest = [manager POST:@"" parameters:params constructingBodyWithBlock:^(id formData) {
    
    
    } success:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog@"response ---%@,responseObject";
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    }];
    
    [apiRequest start];
    

提交回复
热议问题