cancel
Showing results for 
Search instead for 
Did you mean: 

Change HTTP Status Code of RAP Service

hempelbjr
Explorer
0 Kudos

Hey Experts,

we published an ABAP Restful API (Release 19/09, unmanaged implementation, OData V2), which is consumed by an Azure Function.

We implemented the CREATE behaviour and everything is working well. We just want to implement different answers for the Create or POST event.

So for Example if something is already created we want to return an HTTP Status 208 Already Reported or something similar. So is there any way of changing the status codes without throwing erros ?

Best Regards

Björn

View Entire Topic
tudor_teoteoi
Explorer

I can confirm that this probably can't be done in ABAP Platform 2021.

By debugging, I managed to find class CL_SADL_GW_DPC_UTIL, method GET_HTTP_STATUS_FOR_FAILURE, where the HTTP code is determined as a mapping from an internal field called "failure reason".

(This field "failure reason" is set to "NON_SPECIFIC" by default and only changed by the RAP runtime for very specific errors. Programmers of RAP services can't touch it.

No HTTP code is actually mapped to this "failure reason" - it will be later set to 400 by a subsequent routine -.)

There is an internal field %FAIL_INFO used as basis for the "failure reason", but I could not find a way to set it. Even if you could, you are quite limited, unless you enhance the above class and/or modify the constant list for "failure reason".