i have a read operation on an OData Set in which i pass the key. If the key is a string all works fine, but now we switched from String as key datatype to guid as data type and the read call doesn't work anymore. I receive always BAD Request 400.
Here the solution with the String parameter, which works.
var oModel = this.getView().getModel();
var someKey = "Key 1";
oModel.read("/SomeSet('" + someKey + "')", {
urlParameters: {"$expand":"SomeItemToExpand"},
success: function (oData, oResponse) {
sap.m.MessageToast.show("Read successfulf");
},
error: function (onError) {
sap.m.MessageBox.error("Error reading");
}
});
How to pass a guid? I tried:
oModel.read("/SomeSet(guid'" + someKey + "')"
but dows not work.
I finally figured it out the best way pass a guid is:
oModel.read("/SomeSet(SomeKey=guid\'" + someKey + "\')", {
SomeKey= is the key name and this part is optional.