While making a post
request using httpClient
, I am receiving a null
response despite the request being processed successfully.
File: serviceClass.ts
this.httpOptions = {
headers: new HttpHeaders(
{
'Content-Type': 'application/json; charset=utf-8',
'tenant-code' : 'VdoFWiHL8RFR8fRGNjfZI=',
'Authorization': 'Basic ' + btoa('pass:username')
})
}
public Reprocess(ObjProduct) {
var Jobj=JSON.stringify(ObjProduct);
return this._http.post(this.ReprocessUrl,Jobj,this.httpOptions)
}
When invoking the above method in the Component, the response from the API is null
.
Component Code
var op = this.objService.reprocess(this.reprobj);
console.log("output: ", op);
The value of op
seems to be incorrect, displaying _scaler=false
among other things. How can I obtain the accurate status of the service call?
Edit 1: Making the same request from Postman yields a status of Ok 200
.
Edit 2: The code below is also resulting in a null
response (as per the @Spart_Fountain's answer)
var op= this.restApi.Reprocess(this.reprobj).subscribe((data:any) => {
console.log("data "+ data);
});
Postman header screenshot