cancel
Showing results for 
Search instead for 
Did you mean: 

How to Retrieve Response Messages in CRUD Operations in SAP BTP SDK for IOS ?

danielesteban1
Explorer
0 Kudos

When developing the backend in ABAP, I typically add messages to the OData response using the following method:

lo_message_container->add_messages_from_bapi(
EXPORTING
it_bapi_messages = lt_return
iv_add_to_response_header = abap_true ).

Now, in Swift, I'm making a call to update an entity with the following sentence:

await let pUpdate = myOdata.dataService!.updateEntity(myRecord)

The challenge I'm facing is that I don't know how to retrieve the messages sent by the backend. Despite going through the documentation thoroughly, I couldn't find information on accessing the response. Therefore, I'm seeking your assistance.

Thanks!

View Entire Topic
matthiasdelaroc
Advisor
Advisor

Hi Daniel,

you can access the returned header by using this code:

                let responseHeaders = SAPOData.HTTPHeaders()
let options = SAPOData.RequestOptions()
options.captureResponseHeaders = responseHeaders
let updateResponse = try await self.dataService.updateEntity(self.entity, options: options)
print("this is the header : \(responseHeaders.toString()) returned ")

The response is most probably in the header field SAP-Messages.

See https://help.sap.com/doc/saphelp_nw74/7.4.16/en-US/01/a226519eff236ee10000000a445394/content.htm?no_...

danielesteban1
Explorer
0 Kudos

Thank you for your response, it works