简体   繁体   中英

OData : Why am I getting HTTP 428 (Precondition Required) error while performing an update

So here's my code

sap.ui.getCore().getModel("myModel").update("/ZSystemNameSet(mandt='001')", data, null, function(datay, responsey){
            sap.ui.getCore().getModel().refresh();
            MessageToast.show("It worked...!! Data: "+datay+"Response: "+responsey);
        }, function(datax,responsex){
            MessageToast.show("Sorry! Data: "+datax+"Response: "+responsex);
        });

Also how do I add the header attributes to the update() call?

Obviously your service uses optimistic locking and expects an If-Match header, containing the ETag of the entity, in the request. You can pass this ETag as parameter to the update method. For further details you should check your service definition and the documentation.

Regarding the update of header attributes: It is hard do answer as there is no information regarding your entity orchestration. Normally you should be able to add a property containing the update information for you header to the data structure you send to the server, eg if the header is reachable from your entity ZSystemName via association "Header" you do the following:

data.Header = { "attribute1" : value1, "attribute2" : value2 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM