I'm currently learning about web APIs and I'm encountering an issue that I'm hoping someone can help me with.
I have an ASP.NET Core Web API running in the background, and an Angular (version 15.1.5) application running in the frontend. When I call one of my API endpoints in Postman (with GET) and include a customized header, I get a response body (header itself) back as expected. However, when I make the same request from my Angular application, I receive an empty body. I am expecting the header that I passed in Postman shows in my frontend.
How can I troubleshoot this issue?
Postman call can be found also in the attachment
I have attempted several troubleshooting steps to address an issue I'm encountering, but have been unable to resolve it. Specifically, I am developing an Angular application that communicates with an ASP.NET Core Web API, and I am finding that when I make a request to one of my API endpoints from my Angular application, the response body is empty, despite successful execution of the underlying code.
To further investigate the issue, I have inserted console.log
statements into my code and have confirmed that it is running properly up to the point where the request is made. However, the response body remains empty.
I would also like to confirm whether or not a parameter passed in Postman should be visible in the frontend of my application. Additionally, I have noticed that Swagger UI is showing an empty string, which may be related to my issue.
How can I resolve this issue?
You have to add a GUID string to headers:
let headers = new Headers();
headers.append('X-CM-SSO-ACCOUNTGUID','<GUID>');
....
return this.http
.get(this.apiEndpoint, {headers:headers, ...}
....