2021 Jun 02 12:35 PM
Hi,
I am requested OData service with the batch request, which includes multiply POST requests in separated changesets.
How it looks:
--batchContent-Type: multipart/mixed; boundary=changeset--changesetContent-Type: application/httpContent-Transfer-Encoding: binaryPOST Entity HTTP/1.1Content-type: application/json{ <JSON BODY>}--changeset----batchContent-Type: multipart/mixed; boundary=changeset--changesetContent-Type: application/httpContent-Transfer-Encoding: binaryPOST Entity HTTP/1.1
Content-type: application/json
{
<JSON BODY>
}--changeset----batch--
Response structure:
--7070D8610D18DD62D307574F0D9BD4A30Content-Type: multipart/mixed; boundary=7070D8610D18DD62D307574F0D9BD4A31Content-Length: 7416--7070D8610D18DD62D307574F0D9BD4A31Content-Type: application/httpContent-Length: 7247content-transfer-encoding: binaryHTTP/1.1 201 CreatedContent-Type: application/atom+xml;type=entryContent-Length: 6975dataserviceversion: 2.0location: <path><xml entry>--7070D8610D18DD62D307574F0D9BD4A31----7070D8610D18DD62D307574F0D9BD4A30Content-Type: multipart/mixed; boundary=7070D8610D18DD62D307574F0D9BD4A31Content-Length: 7416--7070D8610D18DD62D307574F0D9BD4A31Content-Type: application/httpContent-Length: 7247content-transfer-encoding: binaryHTTP/1.1 201 CreatedContent-Type: application/atom+xml;type=entryContent-Length: 6975dataserviceversion: 2.0location: <path><xml entry>--7070D8610D18DD62D307574F0D9BD4A31----7070D8610D18DD62D307574F0D9BD4A30--
QUESTIONS:
1)Is it possible to parse the response body to an array of separated objects?
2)Are the any options to define key, which returns in response(my case: 7070D8610D18DD62D307574F0D9BD4A30, 7070D8610D18DD62D307574F0D9BD4A31)
Thanks.
2021 Jun 02 10:33 PM
2021 Jun 03 1:01 PM
2022 Apr 14 10:31 AM
2022 Apr 14 10:57 AM
Hi tonyhallow,
you can analyse the responses from the collection oData.__batchResponses
For example:
this.getModel().submitChanges({
groupId: 'changes',
success: oData => {
if (oData.__batchResponses.some(oResult => oResult.response && oResult.response.statusCode === '400')) {
RegardsThorsten
2022 Apr 14 11:35 AM
2022 Apr 14 12:29 PM
Hi Zoe,
I assume you using this Method?
sap.ui.model.odata.v4.ODataContextBinding - API Reference - Demo Kit - SAPUI5 SDK (ondemand.com)
If you want to retrieve the message, you can check the Message Model
// set message model
oMessageManager = sap.ui.getCore().getMessageManager();
this.getView().setModel(oMessageManager.getMessageModel(), "message");
Basic OData Messages - Samples - Demo Kit - SAPUI5 SDK (ondemand.com)
2022 Apr 20 3:29 AM
Thanks, I can read the message through MessageManager now, but I have a new problem here, I need to access numericSeverity from the sap-message, cause I need this property to determine whether if it is a success message or an error message, do you how to do this?