Ошибка 405 с JIRA REST API с использованием узла js - PullRequest
0 голосов
/ 30 апреля 2019

Я пытаюсь создать автоматический билет JIRA с использованием REST API, но получаю сообщение об ошибке 405.

Я использую примеры здесь: https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/

Кроме того, когда я посещаю URL-адрес публикации, я не получаю никаких ошибок, поэтому сомневаюсь, что это проблема сервера.Любые идеи?

var Client = require('node-rest-client').Client;
client = new Client();
// Provide user credentials, which will be used to log in to Jira.
var loginArgs = {
    data: {
        "username": "user",
        "password": "pass"
    },
    headers: {
        "Content-Type": "application/json"
    }
};
client.post("https://jira.mydomain.com/rest/auth/1/session", loginArgs, function(data, response) {
    if (response.statusCode == 200) {
        //console.log('succesfully logged in, session:', data.session);
        var session = data.session;
        // Get the session information and store it in a cookie in the header
        var args = {
            headers: {
                // Set the cookie from the session information
                cookie: session.name + '=' + session.value,
                "Content-Type": "application/json"
            },
            data: {
                // I copied this from the tutorial
                "fields": {
                    "project": {
                        "key": "REQ"
                    },
                    "summary": "REST ye merry gentlemen.",
                    "description": "Creating of an issue using project keys and issue type names using the REST API",
                    "issuetype": {
                        "name": "Request"
                    }
                }
            }
        };
        // Make the request return the search results, passing the header information including the cookie.
        client.post("https://jira.mydomain.com/rest/api/2/issue/createmeta", args, function(searchResult, response) {
            console.log('status code:', response.statusCode);
            console.log('search result:', searchResult);
        });
    } else {
        throw "Login failed :(";
    }
});

Я ожидаю, что будет создан билет Jira типа REQ с деталями, которые я добавил в разделе полей.

1 Ответ

0 голосов
/ 09 мая 2019

Я полагаю, вы используете неправильный API REST;в настоящее время вы выполняете POST для Get метаданных мета , для которой требуется метод GET, следовательно, вы получаете 405. Если вы хотите создать проблему, пожалуйста, используйте Createвместо (POST /rest/api/2/issue).

...