I have a problem post complex object with rxjs observable ajax.
updateCashDesck():Observable<SomeModel>{
return Observable.ajax({
body: {id:5,Stocks:[{WarehouseId:5,WarehouseName:"1235"}]},
url:this._apiServerUrl,
method:"POST"
}).map(r=>{
return new SomeModel(r.response);
}).catch((e,r)=>{
console.log(e);
return Observable.throw(e);
});
}
The problem is that. When ajax send request it set content-type as:Content-Type:application/x-www-form-urlencoded; charset=UTF-8 and request data post as:
Id:5
Stocks:[object Object]
So my MVC controller does not see Stocks (Stocks: count=0).
How can i change Content-Type in Observable.ajax to application/json?