POST Bulk JOSN to RESTful Service of Content type JSON

Hi Team,
I was trying to submit a JSON object from UI using the dhx.ajax().post(),
The Server side code is identifying the response based on the content type,

Like in Jersey @consume(MediaType.APPLICATION_JSON)

So always server side expect these things from UI

  1. POST action
  2. RequestHeader will be application/JSON

I gone through the touchui_deubug.js source file and found this code, right now i was confused on this, that whether i will be able to handle my use case.

if (this.post)
x.setRequestHeader(‘Content-type’,‘application/x-www-form-urlencoded’);

I tried the following code from the given sample

var result = dhx.ajax().post(“http:localhost/grid/submit”,
{
“itemId”:“1”,
“itemCount”:“3”,
“name”:“Hello T1”,
“description”:“30”,
“orders”:{
“itemId”:“1”,
“itemCount”:“3”,
“name”:“Hello T1”,
“description”:“30”
}
} , function(json){
alert(“Hello”);
});

As the request header type is different , it was not even triggering to restful service . the same thing is working with
an advanced rest client with POST , application/json as request header.

Can any body help to fix this issue ?

Looking forward to hear from you .

~ Sabin

The code of dhtmlxTouch doesn’t allow to define content type of ajax request.
API which you are using do the ajax request , but it will be

In case of dhtmlxTouch 1.2 you can use

dhx.ajax().header("Content-type:application/json").post(url, data, callback);

This is is not working as such , I used dhtmlxTouch_v10_111114 for trying out .

this is code i used ,

dhx.ajax().header(“Content-type:application/json”).post(“http://localhost/rest/json”,
“{
“id”:“1”,
“name”:“viz”
}”, null);

and also , was throwing an exception,

TypeError: dhx.ajax().header is not a function .

I hope probably we need to write separate AJAX call inside this , which doesn’t seems to be good .

I was trying this for the whole day , Can you please help to sort this dhx.Ajax functionality itself

~ Sabin

Also , i tried with dhtmlxTouch_v12_120913 . which is also not working ,.

~ Sabin

Was not implemented in 1.0, but works for 1.2
Check the attached screen


Yea it is submitting , as from the screen shot , it is giving 404 , page not found , this is the same
issue we are also facing,

I will send the screen shot of my test from rest client , where it fails in Dhtmlx