Request / Ajax doesn't work well for my API

This is real working JQUERY ajax code

66688nt%C4%B1s%C4%B1

$.ajax({

            url: "http://my-file-upload-url",
            method: 'post',
            crossDomain: true,
            contentType: 'application/json',
            dataType: 'json',
            processData: false,
            beforeSend: function (request) {

                request.setRequestHeader("Authorization", token);

            },

            data: JSON.stringify(data),
            success: function (response) {

                console.log(response);//result 1

            }

        });

But app.request dosn’t work

result : authorization error.

5555s%C4%B1

app.request({

                url: "http://my-file-upload-url",
                method: 'post',
                crossDomain: true,
                data: JSON.stringify(new Image(image).data),
                dataType: 'json', 
                contentType: 'application/json',
                processData: false,
                async:false,
                headers: {

                    Authorization: token,

                },   
                success: function(result) {

                    console.log(result); //result 0
               
                    }    
                },     

              });

Have you tried

Authorization: "Bearer " + token

Yeah, I tried. But the error was not header. I’m converting the picture in base64. I get 500 error on server. But this API is being used. An already successful working api

If the picture is sent blank, it works and saves the picture blank.

function getBase64(file,callback,text) {

    if(!file){
        callback(false);
        return false;
    }

    var image = [];
    image.name =file.name;
    image.type = "image/"+file.name.substring(file.name.lastIndexOf('.')+1, file.name.length);
    image.text = text ? text : null;

    var reader = new FileReader();

    reader.readAsDataURL(file);

    reader.onload = function () {

      image.content = reader.result;

      callback(image);

    };

    reader.onerror = function (error) {    
        callback(false);
    };

 }

This code doesn’t look correct to me at all:

    var image = [];
    image.name =file.name;
    image.type = "image/"+file.name.substring(file.name.lastIndexOf('.')+1, file.name.length);
    image.text = text ? text : null;

Why image is Array? I guess it should be an object:

var image = {}

All the code is here.

Delete from base64 image string : data:image/png;base64, // this is related to my API

     getBase64(file,function(result){

         var image = new Image(result);//my image class

     }

    function getBase64(file,callback,text) {

        if(!file){

            callback(false);

            return false;

        }

        var image = [];

        image.name =file.name;

        image.type = "image/"+file.name.substring(file.name.lastIndexOf('.')+1, file.name.length);

        image.text = text ? text : null;

        var reader = new FileReader();

        reader.readAsDataURL(file);

        reader.onload = function () {        

          image.base64 = reader.result.split(',')[0]+',';

          image.content = reader.result.substr(reader.result.indexOf(',') + 1);

          console.log(image);

          callback(image);

        };

        reader.onerror = function (error) {        

            callback(false);

        };

     }