I'm using ASP .Net Core web API & Angular here. Both the 'code' & 'pageInfo' values are shown correctly in the console, but when passed to the API, the String value is passed correctly only, the object values are showing wrong value (0 and null).
API-
[HttpPost("get/{code}/{pageInfo}")]
public IActionResult Get(string code, Model pageInfo)
{
var data = _Service.GetData(code, pageInfo);
if (data != null)
{
---
}
else
{
---
}
}
Service-
getAllData(code:any,pageInfo:any):Observable<any>{
console.log(code, pageInfo);
const url = `/get/${code}/${pageInfo}`;
return this.http.post<any>(url, code, pageInfo);
}
Can anyone help me to find what mistake I've made here?
I have solved my issue by some modifications-
API-
[HttpPost("get/{code}/{pageInfo}")]
public IActionResult Get([FromBody] Model pageInfo, string code)
{
var data = _Service.GetData(pageInfo, code);
if (data != null)
{---}
else
{---}
}
Service-
getAllData(pageInfo:any, code:any):Observable<any>{
const url = `/get/${code}`; // have passed only the string value via URL
return this.http.post<any>(url, pageInfo, code);
}