Skip to Content
0

oModel.update is not working . PUT method showing Error 400 -BAD REQUEST

Jun 16, 2017 at 10:46 AM

379

avatar image
Former Member

Hi,

I am working on XSODATA and trying to update a table with UI5 screen. I am updating a table using oModel.Update method but getting error as 400 Bad Request(Request contains properties that do not exist in entity 'measuredef_serviceType)

Also my Request Payload is showing the correct data which I'm trying to post. I'll post the screenshots also.

Update coding :

		 oContext = oTable.getContextByIndex(iSelectedIndex);
		var oModel = oTable.getModel();
		console.log(oContext.sPath);
//			//var sPath = oEvent.getParameter("oContext").getPath();


			
			var data  = oModel.getProperty(oContext.sPath);
			var low = data.Low;
			var high = data.High;
			var option = data.Option;
			var hier = data.Hier_Level;
			
			$("#option").val(option);
			$("#low").val(low);
			$("#high").val(high);
			$("#hier").val(hier);
			
		}
	
	},
	
	save : function(){
		
		var mNewEntry = {};
		
		mNewEntry.Option = sap.ui.getCore().byId("option").getValue()
		alert(mNewEntry.Option);
		mNewEntry.Low = sap.ui.getCore().byId("low").getValue();
		console.log(mNewEntry.Low);
		mNewEntry.High = sap.ui.getCore().byId("high").getValue();
		mNewEntry.Hier_level = sap.ui.getCore().byId("hier").getValue();


	
		oModel.update(oContext.sPath,mNewEntry,null,function(oData){
			
			alert("Updated");
//			sap.m.MessageBox.show(
//					"Records updated Successfully.",{
//						icon : sap.m.MessageBox.Icon.SUCCESS,
//						title : "Dear User",
//						styleClass : "sapUiSizeCompact"
//					});
		}, function(err){
			
			alert("Failed");

**************************
My Entity :

<EntityType Name="measuredef_serviceType">
<Key>
<PropertyRef Name="ID"/>
<PropertyRef Name="Measure"/>
<PropertyRef Name="Source"/>
<PropertyRef Name="Dimension"/>
<PropertyRef Name="Seq_no"/>
</Key>
<Property Name="ID" Type="Edm.Int32" Nullable="false"/>
<Property Name="Measure" Type="Edm.String" Nullable="false" MaxLength="50"/>
<Property Name="Source" Type="Edm.String" Nullable="false" MaxLength="3"/>
<Property Name="Dimension" Type="Edm.String" Nullable="false" MaxLength="20"/>
<Property Name="Seq_no" Type="Edm.String" Nullable="false" MaxLength="10"/>
<Property Name="Sign" Type="Edm.String" MaxLength="2"/>
<Property Name="Option" Type="Edm.String" MaxLength="2"/>
<Property Name="Low" Type="Edm.String" MaxLength="10"/>
<Property Name="High" Type="Edm.String" MaxLength="10"/>
<Property Name="Hier_Level" Type="Edm.Int32"/>
</EntityType>

***********************************
Request Payload :

<a:entry xmlns:a="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"><a:author><a:name/></a:author><a:content type="application/xml"><m:properties><d:Option>BT</d:Option><d:Low>680499</d:Low><d:High>680500</d:High><d:Hier_level>1</d:Hier_level></m:properties></a:content></a:entry>
error.png (14.5 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Jun Wu Jun 16, 2017 at 04:27 PM
1
mNewEntry.Hier_level 


Hier_Level



L in uppercase
Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thanks a lot Jun Wu for the answer.

Was really struggling with this error but couldn't figure out this small mistake.

0