从命令行使用curl创建JIRA问题

laz*_*bit 5 rest curl jira

我在这里浏览过文档根据这些文档我正在为JIRA创建问题。我知道我犯了一些小错误。我正在尝试从命令行创建新的JIRA请求(稍后将其集成到Java代码中),我正在从Mac终端运行:

    curl -D- -u username:password -X POST --data {"fields":{"project":{"key": “PROJECTKEY"},"summary": "REST ye merry gentlemen.","description": "Creating of an issue using project keys and issue type names using the REST API","issuetype": {"name": "Bug"}}} -H "Content-Type: application/json" https://mycompanyname.atlassian.net/rest/api/2/issue/
Run Code Online (Sandbox Code Playgroud)

我相信这与“数据”有关。提前致谢。该示例取自文档链接本身。

输出:我的终端什么也没有,没有错误,没有预期的输出。

PROJECTKEY是从我的仪表板中“所有项目”列表的KEY列中提取的。

Han*_* Z. 6

发生了两件事:

  1. 您需要将要发布的数据放在引号中
  2. 围绕PROJECT_KEY的第一个双引号是一个Unicode字符,而不是常规的双引号,因此将其更改“PROJECTKEY""PROJECTKEY"

这应该工作:

curl -D- -u username:password -X POST --data '{"fields":{"project":{"key": "PROJECTKEY"},"summary": "REST ye merry gentlemen.","description": "Creating of an issue using project keys and issue type names using the REST API","issuetype": {"name": "Bug"}}}' -H "Content-Type: application/json" https://mycompanyname.atlassian.net/rest/api/2/issue/
Run Code Online (Sandbox Code Playgroud)