I try to update the identity of a worker on my project, I use HttpClient with a put, working in Angular 6 project and web API 2 on .NET Core. You can see here the request on the front-end side:
updateWorkerIdentity(worker: WorkerRead) : Observable<WorkerRead> {
const url = 'workerinfo/activeContractId=' + worker.activeContract.id;
return this.httpClient.put<WorkerRead>(url , JSON.stringify(worker) );
}
And at the API side:
[HttpPut("{activeContractId}")]
public async Task<IActionResult> Put([FromRoute] string activeContractId, [FromBody] WorkerRead worker)
{
var companyId = GetCompanyId();
var period = GetPeriod();
var language = GetLanguage();
var workerInfo = await _workerInfoService.UpdateWorkerIdentity(companyId, activeContractId, language, worker);
return Ok(workerInfo);
}
the activeContractId
coming from the [FromRoute]
is well sent but the worker is still null.
The worker sent from the body is well sent as you can see here in the payload:
and the Content-Type of the header is well application/JSON
.
Anyone has an idea?