在jira中,我有一个名为“ Abc Def管理”的项目。当我尝试使用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编码。

08-26 23:40
查看更多