Hello All,
I am needing some assistance in knowing how to handle an HTTP OPTIONS request. I have a front end JavaScript developer that is performing an AJAX request to my gateway URL expecting JSON in return. I can execute my gateway URL with the ?format=json parameter, and it renders correctly in the browser. In speaking with my JS developer, his call to my URL is failing because SAP is not handling the OPTIONS request. Specifically, I need set the header information on the OPTIONS request to allow for CORS processing.
Evidently, an AJAX request makes an OPTIONS request before the specified request (GET, POST, etc…). Therefore, I need to set the header data on the Options request. Any help would be appreciated.
I have created a service in SEGW and have added the following code to the method USR01SET_GET_ENTITYSET. I need to find the method that handles the OPTIONS request.
data: ls_header type ihttpnvp.
ls_header-name = 'Access-Control-Allow-Origin'.
ls_header-value = '*'.
/iwbep/if_mgw_conv_srv_runtime~set_header( ls_header ).
ls_header-name = 'Access-Control-Allow-Credentials' .
ls_header-value = 'true' .
/iwbep/if_mgw_conv_srv_runtime~set_header( ls_header ).
ls_header-name = 'Access-Control-Allow-Headers' .
ls_header-value = 'Content-Type, Authorization' .
/iwbep/if_mgw_conv_srv_runtime~set_header( ls_header ).
ls_header-name = 'Access-Control-Allow-Methods' .
ls_header-value = 'POST, GET, OPTIONS, PUT, DELETE, HEAD' .
/iwbep/if_mgw_conv_srv_runtime~set_header( ls_header ).
Thanks in advance!
Allen