Skip to Content

Bad request from sapui5 odata

Hello community,

Right now i'm triying to create an entry, well i'm jus testing that my odata is receiving the info, so i create an odata with my entity CrearSet and activate the check of creatable, put some break-points to debugg when my app sapui5 send the info but is not receiving nothing

now, this is my controller/function that fire my event/odata i'm using odata v2

// "sap/ui/model/odata/v2/ODataModel",
...
function(Jquery, Controller, MessageToast, JSONModel, ODataModel, ManagedObject, validRut, ODataModeII) {
...

onCrear : function() {
    var mensajeOkCreado = this.byId("mensajeOkCreado");
    var mensajeNotCreado = this.byId("mensajeOkCreado");
    
    var sURI = "/sap/opu/odata/sap/ZCRM_UX_PROSPECTO_SRV";
    var oModel = new ODataModeII(sURI, true); 
    var oDatosRespuesta = new JSONModel();
    
    var oInfo = {};
    oInfo.rut       = this.byId("crearRut").getValue();
    oInfo.nombres   = this.byId("crearNombres").getValue();
    oInfo.apellidos = this.byId("crearApellidos").getValue();
    oInfo.calle     = this.byId("crearDir1").getValue();
    oInfo.numero    = this.byId("crearDir2").getValue();
    oInfo.depto     = this.byId("crearDir3").getValue();
    oInfo.comuna    = this.byId("crearDir4").getValue();
    oInfo.fijo      = this.byId("crearTlf1").getValue();
    oInfo.movil     = this.byId("crearTlf2").getValue();    
    oInfo.email     = this.byId("crearMail").getValue();
    
    oModel.create("/CrearSet", oInfo, {
          method: "POST",
          success: function(data) {
              mensajeOkCreado.setVisible(true);
          },
          error: function(oError) { 
              mensajeNotCreado.setVisible(true);
          }
    }); 
}

 

So i got this error:

The following problem occurred: 
HTTP request failed400,Bad Request,
   {"error":
      {"code":"/IWCOR/CX_DS_EP_PROPERTY_ERROR/00505692409C1ED6B8FE112855048EDA",
       "message":{"lang":"es","value":"Property 'rut' is invalid"},
       "innererror":{
          "application":{"component_id":"","service_namespace":"/SAP/","service_id":"ZCRM_UX_PROSPECTO_SRV","service_version":"0001"},
       "transactionid":"8242004F04A044C1BE83804994D9432D","timestamp":"20180517183905.6633110",

"Error_Resolution":{"SAP_Transaction":"For backend administrators: run transaction /IWFND/ERROR_LOG on SAP Gateway hub system and search for entries with the timestamp above for more details","SAP_Note":"See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)"},"errordetails":[]}}} - 

this is how i configured my odata:

properties.png

i follow this tutorial : http://www.techippo.com/2016/05/create-data-in-sap-backend-using-odata.html

http://www.techippo.com/2016/09/odata-create-operation-from-sapui5-application.html

properties.png (42.6 kB)
entityset.png (22.6 kB)
method-used.png (7.5 kB)
code-method.png (47.6 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    May 17 at 07:02 PM

    Error message says property 'rut' is is invalid

    check if property with name 'rut' exists in metadata also check the length/data type of the property.

    If data type is Edm.String and length = 4, and you are passing value of length '5' then create operation will result in error.

    Add comment
    10|10000 characters needed characters exceeded

  • Try change oInfo.rut TO oInfo.Rut

    Add comment
    10|10000 characters needed characters exceeded