2016-09-30 331 views
1

在jira中我有一個名爲「Abc Def Management」的項目。當我試圖得到這個項目中的所有問題使用休息Api,我收到以下錯誤。JQL查詢中的錯誤:字符'%'是保留的JQL字符

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

我該如何解決此錯誤?

回答

1

使用空格而不是%20。

您正在使用POST請求,它將在其正文中包含jql,而不是URL的一部分。所以沒有必要對任何東西進行網址編碼。

+0

我也試過這個,但是不行。如果項目名稱是一個單詞,如'abc',那麼它也不會產生任何結果。 –

+0

如果您在jira問題搜索中嘗試使用,您的jql是否會返回任何結果? – GlennV

+1

@Appunni,您需要將項目名稱放在引號中,如下所示:'jql =「Project = \」Abc Def Management \「」' – rorschach