title: XML or JSON in SAPUI5 POST-request?
body: <p>I am trying to post data to an SAP Backend System via an OData-Rest-API. There are a couple of tutorials online on how do that that also provide code samples. What confuses me is the specification of the "Content-Type" in the request header vs the data format in which the request data is actually offered. One code example is from <a href="http://scn.sap.com/community/developer-center/front-end/blog/2012/06/06/sample-ume-application-using-sapui5-and-sap-gateway--part-ii" rel="nofollow">this site</a>:</p>
  
  <pre><code>    OData.request({  
          requestUri:  "http://gwserver:8000/sap/opu/odata/sap/Z_UI5_USER_MAINT_CM/z_ui5_user_maintCollection",  
          method: "POST",  
          headers: {   
                     "X-Requested-With": "XMLHttpRequest",  
                     "Content-Type": "application/atom+xml",  
                     "DataServiceVersion": "2.0",   
                     "Accept": "application/atom+xml,application/atomsvc+xml,application/xml",  
                     "X-CSRF-Token": header_xcsrf_token  
                    },  
          data:{  
                                username: username_var,  
                                title:title_var,  
                                title_p:title_var,  
                                firstname: firstname_var,  
                                lastname: lastname_var,  
                                password: password_var,  
                                department: department_var,  
                                language: language_var,  
                                telephone: telephone_var,  
                                e_mail: email_var,  
                                city: city_var,  
                                country: country_var,  
                                comm_type:"",  
                                fullname:"",  
                                userid:"",  
                                name:"",  
                                islocked:"",  
                                region: ""  
  }},  
  </code></pre>
  
  <p>Now what exactly is the format of "data" in this request? It does not look like XML. This leads to my next question, which is how to format the data of my POST-request. This is code from my web app's controller.js file:</p>
  
  <pre><code>         OData.request({
           requestUri: "proxy/http/XXXXXXXXX/sap/opu/odata/XXXXXXXXX",
              method: "POST",
              headers: {
                  "X-Requested-With": "XMLHttpRequest",
                  "Content-Type": "application/atom+xml",
                  "DataServiceVersion": "2.0",
                  "MaxDataServiceVersion": "2.0",
                  "Pragma": "no-cache",
                  "Cache-Control": "no-store, no-cache",                  
                  "Accept": "application/atom+xml,application/atomsvc+xml,application/xml",       
                  "X-CSRF-Token": "XXXXXXXXXXXXXX"                    
              },
              data: reqData
              },              
              function(data, response){
                  alert('Done POSTing.');                     
              },
              function(err){                  
                  console.log(err);                   
              });
  </code></pre>
  
  <p>I get a working X-CSRF-Token from a GET-request conducted with DHC REST client. Posting to the SAP system via DHC works without problems. 
  What data format shall I store in the reqData variable? I tried assigning a string of the original XML to reqData, but it returns the error message
  <code>no handler for data</code>. The XML data of one entry of my collection is structured as follows:</p>
  
  <pre><code> &lt;content type="application/xml"&gt;
          &lt;m:properties&gt;
              &lt;d:Name m:type="PatientService.PersonName"&gt;
                  &lt;d:Family&gt;Test10&lt;/d:Family&gt;
                  &lt;d:First&gt;Test10&lt;/d:First&gt;
                  &lt;d:Prefix/&gt;
              &lt;d:Title/&gt;
                  &lt;d:Affix/&gt;
              &lt;/d:Name&gt;
              &lt;d:Gender&gt;Female&lt;/d:Gender&gt;
              &lt;d:BirthDate m:null="true"/&gt;
              &lt;d:isActive&gt;false&lt;/d:isActive&gt;
              &lt;d:NationalityISO&gt;DE&lt;/d:NationalityISO&gt;
              &lt;d:BirthCountryISO&gt;DE&lt;/d:BirthCountryISO&gt;
              &lt;d:BirthPlace&gt;Hintertupfing&lt;/d:BirthPlace&gt;
              &lt;d:BirthName/&gt;
          &lt;/m:properties&gt;
      &lt;/content&gt;
  </code></pre>
  
  <p>I have tried around five different XML to JSON converters to convert the XML content, it keeps throwing format errors like</p>
  
  <pre><code>DOMException: Failed to execute 'createElementNS' on 'Document': The    qualified name provided ('d:_m:type') contains multiple colons.(…)
  </code></pre>
  
  <p>And storing my data in an object like this:</p>
  
  <pre><code>{                       
                          Family: "Test10",
                          First: "Anna10",
                          Nationality: "DE",
                          BirthCountry: "DE",
                          BirthPlace: "Hintertupfing"
                          }
  </code></pre>
  
  <p>did not work either.</p>