Hi!
I’m doing an application secured by a token and I need to add it to every calls header. From the docs (docs.dhtmlx.com/api__dataprocess … nmode.html) I have done this:
scheduler.config.xml_date="%Y-%m-%d %H:%i";
scheduler.config.first_hour = 8;
scheduler.config.multi_day = true;
scheduler.config.date_step = "5"
scheduler.init('scheduler_here', new Date(2012, 7, 22), 'month');
scheduler.setLoadMode('week');
var dp = new dataProcessor(api_url+"save.php");
dp.setTransactionMode({
mode:"POST",
headers:{
"X-AUTH-TOKEN": TokenStorage.retrieve()
},
payload:{
"user_id":"12"
}
}, true);
dp.init(scheduler);
Using Firebug I can see that the calls are done using POST and since default is GET I assume it’s working. But there is no sign of the X-AUTH-TOKEN I’m adding (I also don’t see anywhere the payload part but since I don’t even know what it is I just copied from the docs xD).
The “TokenStorage” part works perfectly, I’ve put console.log before this code to check it.
Any help would be appreciated, thanks!
Which version of scheduler you are using? This feature is relative new, and will not work for older builds.
Also, by any chance, are you using any other dhtmlx js files on the page?
I can confirm that this isn’t working for me either.
Specifically, I’m using dhtmlxGrid 4.6. Similarly to above when I use the js object to add custom headers and/or custom data fields I don’t see either show up in the request (checking via chrome dev tools).
Additionally, when the first arg to setTransactionMode is a js object (e.g., setTransactionMode({mode:“POST”}, false)), the second arg (the send-multiple-rows flag) seems to be ignored.
-Jeremiah
I can confirm the issue. The fix will be included in the next build.
If you have a support subscription, please open a ticket, to get the update ASAP.
Hello,
I can confirm that v4.6 still contains the issue with headers/payload. Any alternative to send an additional data to the server side with dataProcessor before the problem is fixed?
Thanks.
The quick response to myself:
Question: Any alternative to send an additional data to the server side with dataProcessor before the problem is fixed?
Answer: The following code did the trick:
grid.setUserData('', 'payload', 'some value');
dp.sendData();
Ok, I know the original question was regarding the headers not the payload, but in case someone is looking for a solution for the payload he/she can find this useful.
Thanks.