cancel
Showing results for 
Search instead for 
Did you mean: 

CORS status error REST API Sap Build Apps

berry1103
Explorer

Dear Builders,

I am following some tutorials on SAP Build Apps (AppGyver). In one of these tutorials I need to connect a restdb.io server with a rest api direct integration.

When I enter the resource url, the API key and click Get Collection on test, the following error message appears: 'Error: TypeError: Failed to fetch. Does the server allow CORS?status: undefined'.

To overcome the problem I have tried everything, including multiple headers. Nothing works. A colleague tried the same in Postmen. Things went well here.

I have followed the tutorial one on one, but it does not dwell on a possible error message. I get stuck.

Does anyone know a solution that I can use? Thank you in advance!

Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Kudos

Did either solution help? Let us know

Accepted Solutions (1)

Accepted Solutions (1)

yogananda
Product and Topic Expert
Product and Topic Expert

berryvanbree

in you restdb.io while generating key .. you can enable CORS

https://restdb.io/docs/apikeys-and-cors#restdb

I just tried with sample example in restdb.io ... I am able to get results without CORS

berry1103
Explorer
0 Kudos

Dear Yogananda,server-2.pngserver-3.png

Thank you for the quick response! I (and my colleagues) started working on the documentation.

The test still gives an error. We don't understand what we're doing wrong. I have attached screenshots of our new configuration.

What are we doing wrong?

Could you please look?

Thank you in advance!

yogananda
Product and Topic Expert
Product and Topic Expert
0 Kudos

berryvanbree

After seeing your screenshot, there is mistake of KEY and which should be x-apikey

berry1103
Explorer
0 Kudos

Sorry for the late response. I was on vacation from there. In the end, the test was successful. The mistake I made was the following. To avoid the CORS error, I had to create a second website key. This website key replaces the original x-api key. Previously I had both an x-api key and an extra website key. This didn't work.

Many thanks again for the help.

Regards,

Berry

jonas_geiser
Employee
Employee
0 Kudos
Hi, how can I solve this problem (CORS -Does the server allow CORS?status: undefined) when I want to use the AI Core API or any other API which is available in the SAP SAP Business Accelerator Hub?

Answers (2)

Answers (2)

berry1103
Explorer
0 Kudos

Sorry for the late response. I was on vacation from there. In the end, the test was successful. The mistake I made was the following. To avoid the CORS error, I had to create a second website key. This website key replaces the original x-api key. Previously I had both an x-api key and an extra website key. This didn't work.

Many thanks again for the help.

Regards,

Berry

Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Kudos

yoganandamuthaiah solution is perfect

If you want an SAP BTP or SAP Build Apps solution, you can of course use a destination and then you can use your original key.

Good luck on your project