My attempts to make a patch and post call to the server are failing as it never reaches the server. Interestingly, the same request works flawlessly in Postman, so I suspect there might be an issue with my code.
Both my post and patch methods are essentially the same, so I will only showcase the patch method below:
protected patch(url: string, body: any): Observable<any> {
let options = this.getRequestOptions(body);
return this.http.patch(this.baseUrl+url, JSON.stringify(body),options);
}
private getRequestOptions(body:any):RequestOptions{
let cpHeaders = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: cpHeaders });
return options;
}
Please note that
this.baseUrl = "http://localhost/blah/api/
and the url parameter is passed as test
.
I would greatly appreciate any assistance or insights on resolving this issue. Thank you in advance!
Update
[HttpPut]
public virtual IHttpActionResult Patch([FromBody]T entity)
{
return Ok(_repository.Patch(entity));
}
[HttpPatch]
public virtual IHttpActionResult WebPatch([FromBody]T entity)
{
return this.Patch(entity);
}
In the comments section below, I have mentioned the presence of a proxy configuration for further context:
{
"/api": {
"target": "http://localhost/QuickQuoteApi",
"secure": false,
"pathRewrite": {
"^/api": ""
}
}
}