Multipart/form-data webix

I have webix upload form in my app. But when I try to upload with api in console I have error 400 bad request (Invalid json message received). I need to have in my request header “multipart/form-data” when i try to upload but I always have application/json in my request header. In my application i have code like this in the beginning :
webix.attachEvent(“onBeforeAjax”, function(mode, url, data, request, headers){
headers[“Authorization”]= CookieService.get(‘token’);
headers[“Content-type”]= “application/json”;
});

As I can see i cannot override content-type. Do you have any idea how can I change content type only when I try to upload documents (somehow to attach event to the upload button) to change content type only when this upload occurs.

Thank you in advance.

you can place some kind of logic in onBeforeAjax handler

webix.attachEvent("onBeforeAjax", function(mode, url, data, request, headers, formData){ 
 if (!formData){
      headers["Authorization"]= CookieService.get('token'); 
      headers["Content-type"]= "application/json"; 
 }
});

The last parameter is not included in the documentation ( will be fixed ) it is the formData structure that does exist only during file uploading calls.

Thanks Maksim as always. It’s working great.