Youtrack - Применить команду к проблеме требует авторизации

Чтобы применить команду к проблеме, я использую этот код:

$.ajax({
         async: false,
         type: 'post',
                    url: "https://golaservices.myjetbrains.com/youtrack/rest/issue/"+e.target.id+"/execute"+"?command="+target.val(),
         cache: "true",
         dataType: "html"

                });

но это вызывает эту ошибку

You have no access to this resource. Try to log in.

that's why i tried putting that first bit of code like this:

$.ajax({
            async: false,
            type: 'post',
            url: "https://golaservices.myjetbrains.com/youtrack/rest/user/login?login=xxx&password=123",
            cache: "true",
            dataType: "html",
            success: function(output, status, xhr) {
                alert(xhr.getResponseHeader('Set-Cookie'));
            }
        }).done(function (data) { 

            console.log("in done");

            $.ajax({
                    async: false,
                    type: 'post',
                    url: "https://golaservices.myjetbrains.com/youtrack/rest/issue/"+e.target.id+"/execute"+"?command="+target.val(),
                    cache: "true",
                    dataType: "html"

                });

            console.log("after done");


        });

но я все еще получаю ту же ошибку, есть идеи, как это сделать?


person Landoulsy Med    schedule 27.09.2017    source источник


Ответы (1)


Конечная точка /rest/user/login уже давно объявлена ​​устаревшей и не рекомендуется для дальнейшего использования. Вместо этого попробуйте постоянные токены. не требует выполнения каких-либо предварительных запросов на вход в систему.

$.ajax({
     type: "post",
     url: "https://golaservices.myjetbrains.com/youtrack/rest/issue/" + e.target.id + "/execute" + "?command=" + target.val(),
     dataType: "json"
     beforeSend: function(xhr) { xhr.setRequestHeader("Authorization", "Bearer " + permanentToken); },
  });
person Jk1    schedule 27.09.2017