Skip to Content
0

Web ide CRUD create entity error 415 unsupported media type json

Jun 21, 2017 at 11:54 PM

73

avatar image
Former Member

Hi ,

I have created an app in web ide tool and trying to POST data from app to gateway odata service. I am facing and error 415 (Unsupported Media Type). This is happening due to content type. I have declared the content type in manifest

"headers": {"X-Requested-With": "X","Content-Type": "application/json; charset=utf-8"},

same header i have set while calling create function

var oEntry ={"Matnr" : "100005","Werks" : "X110","Name1" : "PLANT XXXXX","Labst" : "0.000","Insme" : "1134.000","Speme" : "0.000","Meins" : "BOX","Maktx" : "XXXXXX MILLED PLAIN BOX"};

var oModel = this.getOwnerComponent().getModel("Model declared in manifest");
 oModel.refreshSecurityToken(function(){
  console.log('Succesfully retrieved CSRF Token');},function(){
     console.log('Error retrieving CSRF Token');}, false);
 oModel.setHeaders({"X-Requested-With": "X","Content-Type": "application/json","accept":  "application/json"});

 oModel.create("/Entityet", oEntry,{method:"POST",
        success:function(data){
        alert("success");},
        error:function(e){
         alert("error");}});

error in chrome

error1.jpg

when i put a trace on odata and replay it Content Type is coming as application/x-www-form-urlencoded; charset=UTF-8 instead of application/json.

error2.jpg

Not sure what i am missing in the code.

error is 415 unsupprted media type. please help

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers