Skip to Content

How to enable CORS in WACS?

A common issue when working with RESTful APIs from a web page is the cross-domain Ajax calls.

Here are both tips to help you to make it work with BI4 RESTful webservices:

- verifying Cross-Origin Resource Sharing settings is well configured (activated by default)

- checking that 'X-Requested-With' HTTP header is present

- adding System properties to WACS

Verifying  Cross-Origin Resource Sharing settings

Checking 'X-Requested-With' HTTP header

'X-Requested-With' header must be sent with your Ajax requests in order to trigger the automatic prefight CORS request from the browser (with OPTIONS HTTP verb).

Popular frameworks like JQuery add it for you, however if you are using XMLHttpRequest or XDomainRequest, you have to add it manually.

Example:

xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

Adding System properties to WACS

To authorize all kinds of HTTP methods and HTTP headers, add these System properties to Web Application Container Server.

-Dcom.sap.bip.rs.cors.extra.methods=* -Dcom.sap.bip.rs.cors.extra.headers=*

Tags:
Former Member

No comments