It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Can't make transition via REST API

Hello everybody! I can't make transition via REST because of 401 response code, but I authenticate with right credentials

def authString = "${user}:${password}".getBytes().encodeBase64().toString()

request.addHeader("authorization: Basic ${authString}", "ContentType: application/json")

The response is

Unauthorized (401)
    (function() {
        var contextPath = '';
        var eventBuffer = [];
        function printDeprecatedMsg() {
            if (console && console.warn) {
                console.warn('DEPRECATED JS - contextPath global variable has been deprecated since 7.4.0. Use `wrm/context-path` module instead.');
            }
        }
        function sendEvent(analytics, postfix) {
            analytics.send({
                name: 'js.globals.contextPath.' + postfix
            });
        }
        function sendDeprecatedEvent(postfix) {
            try {
                var analytics = require('jira/analytics');
                if (eventBuffer.length) {
                    eventBuffer.forEach(function(value) {
                        sendEvent(analytics, value);
                    });
                    eventBuffer = [];
                }
                if (postfix) {
                    sendEvent(analytics, postfix);
                }
            } catch(ex) {
                eventBuffer.push(postfix);
                setTimeout(sendDeprecatedEvent, 1000);
            }
        }
        Object.defineProperty(window, 'contextPath', {
            get: function() {
                printDeprecatedMsg();
                sendDeprecatedEvent('get');
                return contextPath;
            },
            set: function(value) {
                printDeprecatedMsg();
                sendDeprecatedEvent('set');
                contextPath = value;
            }
        });
    })();
if(window.WRM._dataArrived)window.WRM._dataArrived();Unauthorized (401)Возникла ошибка с кодом "401 - Unauthorized" при загрузке этой страницы.Basic Authentication Failure - Reason : AUTHENTICATED_FAILEDПерейти на домашнюю страницу Jira

2 answers

Hi,

Could You please clarify code:

request.addHeader("authorization: Basic ${authString}", "ContentType: application/json")

Looks like You try add two headers. First - "authorization: Basic ${authString}", second - "ContentType: application/json". But I suppose it should like next:

request.addHeader("Header title", "header value")

E.g from my groovy:

connection.addRequestProperty("Authorization", "Basic ${authorization}")

B.R.

Hi, this code request.addHeader("authorization: Basic ${authString}", "ContentType: application/json") works properly when I try to do smth via REST API in another instance of Jira. I always use it and it works without any problems

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you