私はASP.NetのWeb APIコントローラーのメソッドを持っています。のHTTP POSTは
public class TaskListModels
{
public int taskId { get; set; }
public string userId { get; set; }
public string taskDetails { get; set; }
public int companyId { get; set; }
public string companyName { get; set; }
public string dueDate { get; set; }
}
私は次のように角度サービスから一部のデータを投稿しようとしています -
public addTask(_newTask: any) {
console.log('Service - TaskListService : Method - addTask : Params - ' + JSON.stringify(_newTask))
this._requestOptions = new RequestOptions({
method: RequestMethod.Post,
url: this.addNewtaskApiUrl,
headers: this.headers,
body: JSON.stringify(_newTask)
});
console.log('ADD New - POST Request Query : ' + JSON.stringify(this._requestOptions));
return this._http.request(new Request(this._requestOptions)).map(this._httpExtractDataService.extractData).catch(this._httpErrorHandlerService.handleError);
}
次のようにデータがブラウザのコンソールに表示されますが、それは私のコントローラメソッドを打つされていません -
POST Request Query : {"method":1,"headers":{"Content-Type":["application/json"]},"body":"{\"taskId\":4,\"taskDetails\":\"Working with Avi for accounting platform project setup\",\"companyId\":4,\"dueDate\":\"2017-05-16\"}","url":"http://localhost:56250/api/Dashboard/addNewTask","withCredentials":null,"responseType":null}
ご協力いただければ幸いです。
ありがとうございました
ここで、あなたは 'addTask'をどこで呼びますか? – echonax
addTaskはservice.Iにおける方法は、このようなコンポーネントでそれを呼び出していますある - 公共updateTask(付けたnewtask:任意){ \t \t \t this._taskListService.addTask(this.newTask)。 } –
はhttpリクエストが送信されましたか?あなたのブラウザのネットワークタブでそれを見ますか?また、ASP.NETの 'addNewTask'は' POST'エンドポイントとして登録されていますか? –