cancel
Showing results for 
Search instead for 
Did you mean: 

How get the property JSON odata sapui5

rubens12
Participant
0 Kudos

I need to get a property JSON in my SAPUI5 Application

 OData.request({
  requestUri : "/sap/opu/odata/sap/ZGW_TRANSF_APPROVAL_SRV_02/zset_transferset",
method : "POST",
headers : oHeaders,
data:oParameters
                },
function(data,request) {
                                                    MessageToast.show("Transferência concluida!");       
 //    location.reload(true);
},          function(err) {
MessageToast.show("fail!");
})

I need to show the OData property messageerror(like a image) in my code instead the message "fail"

Accepted Solutions (1)

Accepted Solutions (1)

rubens12
Participant
0 Kudos

I solved it

MessageToast.show(JSON.stringify(data["messageerror"])); 

Answers (3)

Answers (3)

maheshpalavalli
Active Contributor

Hi,

You can put a debuggere inside the error function and see what kind of data is available inside the err parameter. From there you can write your logic to show the error message.

BTW, I hope there is some good reason that you using OData.request method, Ideally the best and recommended approach is to use the OData api availble in sap ui5 library(specifically V2 version). Then you can make you of feature like message manager which does the error handling automatically without you writing any code.

Best Regards,
Mahesh

Sharathmg
Active Contributor

Use the code, if err is the json ob ject returned from the backend

err.getProperty('/messageerror'))
junwu
Active Contributor
0 Kudos

yourobject.property.property........ keep going until you reached the property

rubens12
Participant
0 Kudos

Hi Jun Wu, thanks for answer.

Sorry but I am not understand how do it in my code, can you show me a example?