2013-07-17 42 views
1

我正在研究一個將調用JQL腳本的Python腳本。我如何去做這件事?如何在Python中調用JQL查詢

curl -D- -u fred:fred -X GET -H "Content-Type: application/json" http://kelpie9:8081/rest/api/2/search?jql=assignee=fred+order+by+duedate 

假設以上是JQL查詢。

這是我到目前爲止,但它得到一個「無效的語法」錯誤。

from grt import executeScript 

querystring = "curl -D- -u fred:fred -X GET -H "Content-Type: application/json"  http://kelpie9:8081/rest/api/2/search?jql=project=QA+order+by+duedate&fields=id,key" 
executeScript(querystring) 

這是我的錯誤:

 File "/home/.spyder2/temp.py", line 19 
    querystring = "curl -D- -u fred:fred -X GET -H "Content-Type: application/json"  http://kelpie9:8081/rest/api/2/search?jql=project=QA+order+by+duedate&fields=id,key" 
                ^
SyntaxError: invalid syntax 
+1

你有什麼問題? – Marcin

+0

您能否提供您所得到的確切錯誤? –

回答

1

你不打開/關閉正確的字符串:

querystring = "curl -D- -u fred:fred -X GET -H "Content-Type: application/json"  http://kelpie9:8081/rest/api/2/search?jql=project=QA+order+by+duedate&fields=id,key" 

應該是:

querystring = """curl -D- -u fred:fred -X GET -H "Content-Type: application/json" http://kelpie9:8081/rest/api/2/search?jql=project=QA+order+by+duedate&fields=id,key""" 

因爲字符串本身包含雙引號。

+0

或者你可以使用''「」''語法 – Marcin

+0

Thanx我得到它的工作。 –

相關問題