從頁面無法獲得發佈的數據我發送數據:角2 - 網頁API:在API
register() {
this.loading = true;
this.Register = { firstName: 'aa', lastName: 'aa', email: 'aa', password: 'aa', cpassword: 'aa', gender: "male", dob: '2017-05-02' };
this.userService.create(this.Register)
.subscribe(
data => {
alert("aa");
},
error => {
// this.alertService.error(error);
this.loading = false;
});
}
我張貼從角2服務代碼我的數據如下:
create(UserRegister: UserRegister) {
return this.http.post('http://localhost:53625/api/UserLoginAPI/InsertUser', UserRegister, this.jwt()).map((response: Response) => response.json());
}
private jwt() {
let headers = new Headers({ 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' });
return new RequestOptions({ headers: headers });
}
爲了這個,我在API編寫代碼如下:
[HttpPost]
public IHttpActionResult InsertUser(UserRegisterModel UserRegister)
{
int returnval = 0;
returnval = objUserLoginBAL.InsertUser(objUserRegisterModel);
return Json(returnval);
}
我會在API方面的電話,但我的目標沒有得到任何價值。所顯示圖像:
是的,我初始化對象 –
你能分享你如何調用創建方法與價值的代碼片段? – Born2Code
你可以嘗試添加標題的請求選項中的正文對象並嘗試? – Born2Code