title: SAPUI5 Create OData entity with dates - generates incorrect request payload that ends in CX_SXML_PARSE_ERROR
body: <p>We are trying to create an entity that has date attributes via an odata service. Backend is an sap system. This entity has only 3 key attributes plus a bunch of other attributes. We have identified that dates in the keys are the root cause of the problem.</p>
  
  <p>Keys:</p>
  
  <ul>
  <li>Pernr type string, </li>
  <li>begda type datetime</li>
  <li>endda type datetime.</li>
  </ul>
  
  <p>The code below, (which does not work), has been severely simplified when trying to troubleshoot the issue. At the moment, it reads an entity from an entity set and immediately tries to create one with exactly the same data.</p>
  
  <p>Code:</p>
  
  <pre><code>var oODataModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/Z_PERSONAL_DATA_SRV/");
  
  //Test entity to be saved
  var entity = null;
  
  //Handler for read error
  var handleReadE = function (oEvent){ 
      alert("error");
  };
  
  //Handler for read success
  var handleRead = function (oEvent){
      //Get the data read from backend
      entity = oEvent.results[0];
  
      //Try to create a new entity with same data
      oODataModel.create('/PersDataSet', entity, null, function(){
          alert("Create successful");
      },function(oError){
          alert("Create failed", oError);
      });
  };
  
  oODataModel.read("/PersDataSet", null, [], true, handleRead, handleReadE);
  </code></pre>
  
  <p>In the gateway error log, an xml parsing error appears. In this log, we can see the request data and it can be seen that the dates are transported with String types. These dates are defined in the service as DateTimes so the request is rejected. 
  Example:</p>
  
  <pre><code>&lt;m:properties&gt;
  &lt;d:Pernr m:type="Edm.String"&gt;00000001&lt;/d:Pernr&gt;
      &lt;d:Endda m:type="Edm.String"&gt;9999-12-31T00:00:00&lt;/d:Endda&gt;
      &lt;d:Begda m:type="Edm.String"&gt;1979-05-23T00:00:00&lt;/d:Begda&gt;
  </code></pre>
  
  <p>When the entity is read, the backend does not send any type information. It sends like the following example:</p>
  
  <pre><code>&lt;m:properties&gt;
     &lt;d:Pernr&gt;72010459&lt;/d:Pernr&gt;
     &lt;d:Endda&gt;9999-12-31T00:00:00&lt;/d:Endda&gt;
     &lt;d:Begda&gt;1876-07-21T00:00:00&lt;/d:Begda&gt;
  </code></pre>
  
  <p>And, indeed, if we try to save the same info without the type=".." it works. So the problem are the incorrect types ODataModel.create adds to the xml.</p>
  
  <p>My question is:
  Can I tell ODataModel.create to not add this type info? It is not doing a good job inferring the types.</p>
  
  <p>Can anyone share an example reading and writing dates through odata? </p>
  
  <p>Thank you very much in advance.</p>