に掲載のデータを取得できません:私は角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;
});
}
は以下の通りです:
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側でコールを取得しますが、私のオブジェクトは、任意の値を取得できません。それは、画像に示されている:
はい私はオブジェクトを初期化します –
createメソッドをどのように値で呼び出すかについてコードスニペットを共有できますか? – Born2Code
ヘッダーのリクエストオプションでbodyオブジェクトを追加してみてみることはできますか? – Born2Code