1

我正在使用 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
4

1 回答 1

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"""

因为字符串本身包含双引号。

于 2013-07-18T12:29:57.423 回答