【问题标题】:Error in the JQL Query: The character \'%\' is a reserved JQL characterJQL 查询中的错误:字符 \'%\' 是保留的 JQL 字符
【发布时间】:2017-02-08 22:28:28
【问题描述】:

在 jira 中,我有一个名为“Abc Def Management”的项目。当我尝试使用 rest Api 解决此项目中的所有问题时,我收到以下错误。

errorMessages: [ 'Error in the JQL Query: The character \'%\' is a reserved JQL character. You must enclose it in a string or use the escape \'\\u0025\' instead.

我正在下面输入我的代码。

client.post("https://xxx.atlassian.net/rest/auth/1/session", loginArgs, function(data, response){
        console.log('Response', 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 searchArgs = {
                headers: {
                    // Set the cookie from the session information
                    cookie: session.name + '=' + session.value,
                    "Content-Type": "application/json"
                },
                data: {
                    // Provide additional data for the JIRA search. You can modify the JQL to search for whatever you want.
                    jql: "project=Abc%20Def%20Management"
                }
            };
            // Make the request return the search results, passing the header information including the cookie.
            client.post("https://xxx.atlassian.net/rest/api/2/search", searchArgs, function(searchResult, response) {
                console.log('status code:', response.statusCode);
                console.log('search result:', searchResult);
            });
            // response.render('index', {
            // });
        }
        else {
            console.log("Login failed");
            // throw "Login failed :(";
        }
    });

我该如何解决这个错误?

【问题讨论】:

    标签: node.js jira jira-rest-api


    【解决方案1】:

    使用空格代替 %20。

    您使用的 POST 请求将在其正文中包含 jql,而不是作为 url 的一部分。所以没有必要对任何东西进行 url 编码。

    【讨论】:

    • 我也试过了,但是不行。如果项目的名称是像 'abc' 这样的单个单词,那么它也不会产生任何结果。
    • 如果您在 jira 问题搜索中尝试,您的 jql 是否返回任何结果?
    • @Appunni,您需要将项目名称放在引号中,如下所示:jql = "Project=\"Abc Def Management\""
    • 有关json字符串中哪些字符需要转义的更多详细信息,请查看此答案:stackoverflow.com/a/27516892/1453994
    • @GlennV 是的,我在 jira 问题搜索中得到了结果
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多