AFNetworking 2.0 add headers to GET request

后端 未结 7 1095
天命终不由人
天命终不由人 2020-12-07 12:20

I\'ve just started using AFNetworking 2.0 and I was wondering how I put in headers into a HTTP Get request. The documentation sets up a GET like this:

AFHTTP         


        
相关标签:
7条回答
  • 2020-12-07 12:50

    I have used this form to make an appointment with a specific header.

    AFHTTPRequestOperationManager *operationManager = [AFHTTPRequestOperationManager manager];
    [operationManager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];
    [operationManager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    
    [operationManager POST:url
                parameters:params
                   success:^(AFHTTPRequestOperation *operation, id responseObject) {
    
                       if (success) {
                           success(responseObject);
                       }
    
                   }
                   failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    
                       NSLog(@"Error: %@", [error description]);
    
                   }
     ];
    
    0 讨论(0)
提交回复
热议问题