node.js - JQL查询错误: The character \'%\' is a reserved JQL character

标签 node.js jira jira-rest-api

在 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 :(";
        }
    });

如何解决此错误?

最佳答案

使用空格代替 %20。

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

关于node.js - JQL查询错误: The character \'%\' is a reserved JQL character,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39789902/

相关文章:

java - 如何访问/myservlet 示例 servlet?

lucene - 在 JIRA 过滤器中排除文本字段的确切字符串

mysql - 如何将我的 MySQL 数据库与 Cloud JIRA 数据库连接?

vba - 即使标签已成功添加,通过 vba 使用 jira api 将标签添加到现有问题时也会收到 'Operation aborted error'

javascript - 大型阵列上的 Node console.log 显示 "... 86 more items"

node.js + socket.io 从服务器广播,而不是从特定客户端广播?

automation - 一旦子问题状态从 "Pending"更改为 "In Development",如何在 Jira 中自动转换父问题?

curl - 在 Keycloak 上创建一个用户,包括来自 curl 命令的密码

javascript - 如何在 Promises 上冒泡错误而不在每个级别调用 `catch`?

javascript - Node.js 等待异步函数完成,然后继续执行其余代码