Quantcast
Channel: SCN : Discussion List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 6412

Error while using oData update (415 Unsupported Media Type Error)

$
0
0

Hi,

I am trying to use oData Update functionality. Below is the code sample. I am trying to do this on HANA instance on AWS.

 

var saveModel = new sap.ui.model.odata.ODataModel("http://ec2-54-213-97-224.us-west-2.compute.amazonaws.com:8000/workshop/sessiona/01/services/MarketInfo.xsodata/", true,null,null,{"Content-Type": "application/json;charset=utf-8"});

                    var oTable = sap.ui.getCore().byId('tableid');

                    var oModel = oTable.getModel();

                    var ModelData = oModel.getData();

                    for(var i = 0 ; i < 1 ; i++)

                              {

                                        var id = ModelData[i].id;

                                        var oEntry = {

                                                    "FRACTION":"4.3",

                                                    "MARKETID" : "00001",

                                                    "YEAR":"2013",

                                                    "MONTH":"08",

                                                    "INDUSTRY":"ENTERTAINMENT"

                              };

                                        var oParams = {};

                                        oParams.fnSuccess = function (){};

                                        oParams.fnError = function () {};

                                        saveModel.update("/MarketInfo('"+id+"')", oEntry, oParams);

 

                              }

 

I have set the bJSON flag to true and also set the Content -Type. However when I run the application I get 415 Unsupported Media Type Error.

 

Below is the trace:

  1. Request URL:http://ec2-54-213-97-224.us-west-2.compute.amazonaws.com:8000/workshop/sessiona/01/services/MarketInfo.xsodata/MarketInfo('00002')
  2. Request Method:PUT
  3. Status Code:415 Unsupported Media Type
  4. Request Headersview parsed
    1. PUT /workshop/sessiona/01/services/MarketInfo.xsodata/MarketInfo('00002') HTTP/1.1 Host: ec2-54-213-97-224.us-west-2.compute.amazonaws.com:8000 Connection: keep-alive Content-Length: 91 Authorization: Basic c3lzdGVtOm1hbmFnZXI= MaxDataServiceVersion: 2.0 Origin: http://ec2-54-213-97-224.us-west-2.compute.amazonaws.com:8000 Accept-Language: en-US User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36 Content-Type: application/json Accept: application/json DataServiceVersion: 2.0 Referer: http://ec2-54-213-97-224.us-west-2.compute.amazonaws.com:8000/workshop/sessiona/01/ui/WebContent/index.htmlAccept-Encoding: gzip,deflate,sdch Cookie: __gads=ID=17a6adb714195f75:T=1371410403:S=ALNI_MYkHmlb5LM1b37EG5BpjK7nqxEcEQ; xsSessionId=B97C7B06BC9D174E8A6C2CA3E183D79C; sapxslb=5D6D1EE6312C454791227AFA22D076A8
  5. Request Payloadview parsed
    1. {"FRACTION":"4.3","MARKETID":"00001","YEAR":"2013","MONTH":"08","INDUSTRY":"ENTERTAINMENT"}
  6. Response Headersview parsed
    1. HTTP/1.1 415 Unsupported Media Type content-type: application/json;charset=utf-8 content-language: en-US content-length: 202 cache-control: no-cache expires: Thu, 01 Jan 1970 00:00:00 GMT

The content type for request header is only application / json and this seems to be creating the problem. Please let me know how I can override the content type.

 

Thanks,

Aamod


Viewing all articles
Browse latest Browse all 6412

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>