cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

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:

saurkhare_0-1716577781488.png

Expected Response:
{ "Success" } or no response at all with HTTP status 200 would also work.

Any suggestions?

@JessieCheah @Andre_Fischer 

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

Sijin_Chandran
Active Contributor
0 Likes

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

Answers (1)

Answers (1)

saurabh__khare38
Participant
0 Likes

 Hi Vitali,

Thank you for your response. I think that would work for us.

Regards,

Saurabh

0 Likes
May i know how you did this , I also have same requirement with unmanaged scenario but when i am trying to add ?$select=FieldName in my post query it is giving me problem that The Data Services Request contains SystemQueryOptions that are not allowed for this Request Type
saurabh__khare38
Participant
0 Likes

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

"message": "The requested URI allows the system query options: '$expand,$format'"
 
So $select does not work. @vhardzeyenka: How did you create your service? Is it a RAP-based service or SEGW?
0 Likes
It’s a RAP based API