I’m building an application to demonstrate to a customer which needs to retrieve information using an API from S/4HANA Cloud. And also Post. However, i’m receiving a CORS error when testing the API and also when previewing the application, no information is displayed giving specific error 400 (not authorized).
Not sure if should be done via API Proxy because i’m not using an AppGyver service from SAP BTP, meaning there is no direct connection to the system.
Anyone encountered such issues while connecting to S/4HANA Cloud APIs?
I’m not an expert on S/4 HANA, but a 400 error sounds like you might be missing some authorization in your request? Does the same request work if you make it from Postman? What’s the specific error message from the Chrome dev tools Network tab (right-click + Inspect → Network)?
Furthermore, I recommend checking out the SAP AppGyver topic page and the SAP Community in general about integrations between SAP systems and AppGyver, you might find something useful there: SAP AppGyver | SAP Community.
There’s also this thread on CORS issues with SAP APIs, maybe something worth checking:
Thank you for the inputs given. I will take a look at both communities and check if anyone find a solution for it.
Responding to your question, i use the same credentials i have set in the respective API and if i try to use it via postman and via browser, both work after entering the credentials of the API.
Meaning, seems to be a specific situation in AppGyver, or being new i’m not yet familiarized with the process of configuring such API.
However, i’ve made some changes in the configuration of the data resource and now there is no error being sent when performing GET action, directly in the Preview app (as i’ve made the configuration to see the error in there). Although in the Test Data Resource, still i receive the CORS error message.
My recommendation is that you do it using SAP API Management as a proxy service to your S/4HANA Cloud APIs. SAP APIM offers an out-of-the-box CORS policy where you can manage additional headers as well; I hope that helps; Piotr