タイトルがそれを説明していると思います。APIコントローラーのGet関数に問題なくアクセスできます。Post メソッドにアクセスできますが、パラメーター (macAddress) が null です。私は xcode でこのコードの多くのバリエーションを試しました:
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",baseURL,controller]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
[request setHTTPMethod:@"POST"];
NSString *postString = @"macAddress=testestest";
NSData *myRequestData = [ NSData dataWithBytes: [ postString UTF8String ] length: [ postString length ] ];
[request setHTTPBody:myRequestData];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
そしてコントローラー:
public String Post([FromBody]string macAddress)
{
//......
}
(私は同期リクエストとnilレスポンス/エラーを使用していることを認識しており、この側面を理解しようとしています)
助けてくれてありがとう。