我有以下的http post请求代码,
FIRDatabaseReference *agreementCreateReference = [[[FIRDatabase database] referenceWithPath:@"/agreements/"] childByAutoId];
NSLog(@"autoId %@",agreementCreateReference.key);
NSLog(@"autoId %@",_propertyId);
NSString *post = [NSString stringWithFormat:@"agreementId=%@&listingId=%@",agreementCreateReference.key,_propertyId];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"https://krib-api-onbit.herokuapp.com/api/agreements"]];
[request setHTTPMethod:@"POST"];
[request setValue:idToken forHTTPHeaderField:@"X-FIREBASE-ID-TOKEN"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSLog(@"%@",request);
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
NSLog(@"data dtat %@",data);
}];
[dataTask resume];
这个带参数和标题的网址会在邮递员中返回数据。当我使用上面的代码使用目标c来获取数据时,我得到<42616420 52657175 6573740a>
作为数据。而且也没有调用后端。