Hi,
We've exposed a RAP service as an OData V4 Web API. It works as expected. Just that the default response of the POST call contains all the fields of the entity and the child entity when the request is successful. Is there a way to control/modify the response body(delete certain fields/send a generic response) before sending it to the consumer? Note that is a managed RAP BO with unmanaged save. The consumer triggers a create request, data is persisted in a custom DB table in the unmanaged save sequence and the control returns to the RAP framework for response generation.
Current default sample response:
Expected Response:
{ "Success" } or no response at all with HTTP status 200 would also work.
Any suggestions?
Request clarification before answering.
Those who all looking for something similar with 'Custom Entities' based RAP BO, we can manipulate the response for POST/CREATE call by using a simple trick.
While triggering a CREATE/POST call, the Framework after executing the METHODs for CREATE and SAVE Sequences , it makes a default call to the QUERY Provider call as well( its a GET call called by Framework after a successful POST call).
So, in the CREATE Method you just keep a Copy of the Request Payload, make changes in the required fields(except KEY fields) and save it in a Global Instance variable probably by making use of a Singleton Class object, then later in the QUERY call check if this structure is filled, if found filled then use this structure's value for filling the Query Class response, else let it continue as usual.
IF lo_assistance_class->gs_create_response IS NOT INITIAL. "Query Class is being called by the framework after the Successful CREATE(POST) call.
APPEND lo_assistance_class->gs_create_response TO lt_data_response.
CLEAR lo_assistance_class->gs_create_response.
ENDIF.
"Fill response
io_response->set_data( lt_data_response[] ).Thanks,
Sijin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vitali,
Thank you for your response. I think that would work for us.
Regards,
Saurabh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
This did not work for us as well using RAP Web API. Not sure if this works in public cloud systems or BTP ABAP env. On on-premise/private cloud it does not.
.../sap/opu/odata4/sap/zfi_api_invoiceapi_o4/srvd_a2x/sap/zfi_api_invoiceapi_o4/0001/InvoiceAPI?sap-client=200&$select=InvUUID
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.