我为此苦苦挣扎了几个小时,我想将 json 字符串发送到 asp.net 服务器,但我总是得到空响应。我的代码有什么问题吗?还是服务器端有问题?多谢..
(网址仅出于安全考虑而隐藏),这是更新代码..
NSError *error;
NSDictionary* jsonDict = @{@"FundCode": @(1), @"TotalAmount":@(1000000), @"PaymentType":@(0), @"Bank":@"AAA BANK",@"BankAccountNo": @"123456789",@"Amount":@"1000000",
@"DepositFile":@"asset.PNG"};
NSData* postData = [NSJSONSerialization dataWithJSONObject:jsonDict options:kNilOptions error:&error];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSURL *url1 = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.url.com"]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url1];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];