cancel
Showing results for 
Search instead for 
Did you mean: 

Getting CORS error while calling product list using JavaScript.

DixanThomas
Discoverer
0 Kudos

I am trying to call a product list API below to get the list of products in a JSON format. I found the API link from the network tab while accessing the SAP API Business HUB.

I can get a response while calling the API directly from the browser. However, I'm getting a CORS error when calling it from Postman or JavaScript.

Also, there are some preflight requests that are being called while calling this API from the browser.

Is there a way to access this API?

Do I need to add an access token to call this API?

Is there any additional permission that needs to be granted?

Accepted Solutions (0)

Answers (1)

Answers (1)

Bruno-Franzini
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Dixan,

You can use two ways to get authenticated by using Destination in your Service Binding or even in your BTP Cockpit, please refer to Authentication Methods in SAP Business Accelarator Hub. You also may check the SAP SDK Cloud if you need them.

Kind regards

Bruno Franzini

DixanThomas
Discoverer
0 Kudos

The error I'm getting is related to CORS. So, shouldn't the server add my domain in allow cross origin domain list in order to complete my request?

Where should that be configured?

Bruno-Franzini
Product and Topic Expert
Product and Topic Expert

Create a destination on BTP Cockpit or a Service-related Destination (MTA file), then bind it to service.
Tutorial: Creating Destination.

Your Destination must have an Authentication Method: Basic, Client Credentials, and etc...

I've faced that issue, and solved it by using BTP Destination.