DataProcessor headers not sending appropriate data.

I have configured a Gantt chart, using the following DataProcessor setup.

      mode: "REST",
      payload: { template_id: $("#template_id").val() }
    }, true)

This works great. However, I also want to add a X-CSRF-TOKEN in my headers. So I do this.

      mode: "REST",
        "X-CSRF-TOKEN": "SomeTokenHere"
      payload: { template_id: $("#template_id").val() }
    }, true)

However, this doesn’t work. The header gets set, but the data process is no longer sending the task params in post request.
What am I doing wrong? Using version 5.05

It seems like you do not recieve data on the server because you’ve set “headers” object, so to keep all task’s data just remove “headers” field from the object, like this
dp.setTransactionMode({mode:“REST”, payload:{“user_id”:“123”}});
To provide custom data within tasks or links, you can add some custom field to the sending data object (i.e. task or link) before updating, for example
dp.attachEvent(“onBeforeUpdate”, function(id, state, data) {
data.my_custom_field = “my custom value”;
return true;
Please see … event.html
So as you can see now the header contains custom field in the request
Also you can use Gantt “ajax” module for custom requests, please see … other.html

Okay, thanks. I figured it out by sending additional data.
Still seems weird to me, if you add headers everything disappears.

FYI - I have found that this code doesn’t work for the GPL version of DHTMLx:

dp.attachEvent("onBeforeUpdate", function(id, state, data) { data.my_custom_field = "my custom value"; return true; });

my_custom_field is not sent in the POST action to the server.

The only way I’ve been able to send custom data to the server using a Tree connector is to set up the data processor like this:

TreeDataProcessor = new dataProcessor("TreeConnector.ashx");

then send additional fields as UserData and then manually trigger the data send:

            treeToolbar.attachEvent('onClick', function (id) {
                        switch (id) {
                            case "addTreeItem":
                                newNodeId = (new Date()).getTime();
                                newNode = myTree.insertNewNext(myTree.getSelectedItemId(), newNodeId, "New Unit");
                                myTree.setUserData(newNodeId, "Commence", "customValue1");
                                myTree.setUserData(newNodeId, "Conclude", "customValue2");
                            case "editTreeItem":
                            case "deleteTreeItem":

The proposed solution above would be far more elegant. Is it specific to REST mode?

Please make sure that you have the latest 5.1 version because in older versions it might not work correctly.
For example, in this snippet you may see that gantt sends the custom field:


var dp = new gantt.dataProcessor("…/common/connector.php");
dp.attachEvent(“onBeforeUpdate”, function(id, state, data) {
data.my_custom_field = “my custom value”;
return true;

Why do you wrote new gantt.dataProcessor instead new dataProcessor in your snippet?
If I write new dataProcessor I don’t get my_custom_field in the POST.
And if I write new grid.dataProcessor, I get error “Uncaught TypeError: grid.dataProcessor is not a constructor” in my grid.

This topic belongs to DHTMLX Gantt subforum, I think, it is expected that the answers primarily related to Gantt component. You can check the following article that explains how to integrate a backend server with Gantt component:
If you have a question related to another DHTMLX component, I think, it is better to create a new topic in the corresponding component subforum:
Maybe the data processor works differently with Grid.