次のPOSTメソッドを使用したWebAPIがあります
public HttpResponseMessage Post([FromBody]string package)
を問題なく使用するコンソールアプリがHttpCLient
あります。を使用して呼び出しを行おうとすると、パッケージ変数jQuery
を取得します。null
これは私が今持っているコードです:
$.ajax({
url: 'http://localhost:8081/api/Package/',
type: 'POST',
data: JSON.stringify(message),
contentType: "application/json;charset=utf-8",
success: function (data) {
alert(data.length);
},
error: function (xhr, ajaxOptions, thrownError) {
alert('Status: '+xhr.status+', Error Thrown: '+thrownError);
}
});
「メッセージ」変数は、2つのプロパティを含む複雑なモデルです。
何が間違っているのでしょうか?
私はあなたの助けに感謝します...