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

放肆的年华 提交于 2019-12-26 05:06:28

问题


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?


回答1:


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, e.g. if the header is reachable from your entity ZSystemName via association "Header" you do the following:

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


来源:https://stackoverflow.com/questions/40210658/odata-why-am-i-getting-http-428-precondition-required-error-while-performing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!