title: How to send json model via REST service using sapui5
body: <p>I'm using SAPUI5 and I have a XML form that I wanna send the data to my REST service using Json Model.</p>
  
  <p>I'm using the SAPUI5 MVC model to make my app.</p>
  
  <p>How can I send the data to my server with REST and JSON?</p>
  
  <pre><code>sap.ui.controller("controller.NewTicket", {
  
      onInit: function() {
          this.router = sap.ui.core.UIComponent.getRouterFor(this);
          this.router.attachRoutePatternMatched(this._handleRouteMatched, this);
      },
      _handleRouteMatched:function(evt){
          if("NewTicket" !== evt.getParameter("name")){
              return;
          }
          var id = evt.getParameter("arguments").id;
          var model = new sap.ui.model.json.JSONModel({id:id});
          this.getView().setModel(model,"data");
      },
  
  
      enviar:function() {
          jQuery.sap.require("sap.m.MessageBox");
  
          // open a fully configured message box
          sap.m.MessageBox.show("Confirmar a abertura do chamado?",
                  sap.m.MessageBox.Icon.QUESTION,
                  "Confirmar",
                  [sap.m.MessageBox.Action.YES, sap.m.MessageBox.Action.NO], 
                  function(sResult) {
              if(sResult == sap.m.MessageBox.Action.YES)    
              {
                  var oModel = new sap.ui.model.json.JSONModel();
                  var aData = jQuery.ajax({
                      type : "POST",
                      contentType : "application/json",
                      url : "http://192.168.0.32:9082/maxrest/rest/mbo/sr/?description="+ **deviceModel.sr.description** +"&amp;_format=json&amp;_compact=true&amp;_verbose=true",
                      dataType : "json",
                      async: false, 
                      success : function(data,textStatus, jqXHR) {
                          oModel.setData({modelData : data}); 
                          sap.m.MessageBox.show("ABRIU");
                      },
                      error : function(data,textStatus, jqXHR) {
                          oModel.setData({modelData : data}); 
                          sap.m.MessageBox.show(textStatus);
                      }
              })}
              else 
             {
             }
          },
                  sap.m.MessageBox.Action.YES);
  
          var deviceModel = new sap.ui.model.json.JSONModel({
              sr : [{
                  description: "",
                  long_description: ""
              }]});
          deviceModel.setDefaultBindingMode("TwoWay");
          sap.ui.getCore().setModel(deviceModel);
  
          jQuery.sap.require("sap.m.MessageToast");
          sap.m.MessageToast.show(deviceModel.getData().sr.description);
      }
  
  });
  </code></pre>
  
  <p>And the View...</p>
  
  <pre><code>&lt;mvc:View xmlns:mvc="sap.ui.core.mvc" displayBlock="true" xmlns="sap.m" xmlns:co="sap.ui.commons"
  xmlns:f="sap.ui.layout.form" xmlns:core="sap.ui.core" controllerName="com.maximo.controller.NewTicket"&gt;
  
  &lt;Page id="NewTicket" enableScrolling="true" title="{i18n&gt;newTicket}" &gt;
      &lt;content&gt;
              &lt;f:SimpleForm &gt;
                  &lt;core:Title level="H5"
                      text="O chamado será aberto em seu nome e você será o usuário afetado"/&gt;
                  &lt;Label text="Resumo"/&gt;
                  &lt;Input type="Text" maxLength="100" value="{/sr/description}"/&gt;      
                  &lt;Label text="Detalhes"/&gt;      
                  &lt;TextArea height="50%" cols="800" value="{/sr/long_description}"/&gt;  
              &lt;/f:SimpleForm&gt;
      &lt;/content&gt;
      &lt;customHeader&gt;
          &lt;Bar&gt;
              &lt;contentLeft&gt;           
                  &lt;Button icon="sap-icon://nav-back" press="voltarMenu"/&gt;
              &lt;/contentLeft&gt;
              &lt;contentMiddle&gt;
                  &lt;Label text="{i18n&gt;newTicket}"/&gt;
              &lt;/contentMiddle&gt;
          &lt;/Bar&gt;
      &lt;/customHeader&gt;
      &lt;footer&gt;
          &lt;Bar&gt;
              &lt;contentMiddle&gt;
                  &lt;Button id="btnSend" text="{i18n&gt;send}" press="enviar" icon="sap-icon://add-activity-2"/&gt;
              &lt;/contentMiddle&gt;
          &lt;/Bar&gt;
      &lt;/footer&gt;
  &lt;/Page&gt;
  </code></pre>
  
  <p></p>