代码之家  ›  专栏  ›  技术社区  ›  Milister

基于问题名称/描述的JIRA JQL CURL搜索(基于名称获取票证ID)REST API

  •  2
  • Milister  · 技术社区  · 7 年前

    我需要根据摘要和描述字段获取Jira票证ID

    curl -D- -u user:password -X GET -H "Content-Type: application/json" https://jira.corp.company.com/rest/api/2/search?jql=project="Technology" and summary="Check o365 license"
    

    但是得到了 curl: (6) Could not resolve host: summary=Check o365 license Unknown error

    仅在摘要字段上搜索时,没有错误,但没有结果

    下面是我用作搜索过滤器的票证的一些输出(摘要和描述)

        "customfield_10600":null,"customfield_10204":null,"customfield_11019":null,"customfield_10205":null,"customfield_10206":null,"attachment":[],"aggregatetimeestimate":0,**"summary":"Check o365 license"**,"creator"
    "components":[],"timeoriginalestimate":57600,"description":"Check office 365 license" 
    

    我可以按项目和受让人筛选

    jql=project=Technology+AND+assignee=user 
    

    但按描述和/或摘要搜索时,现在没有错误,也没有结果:(

    2 回复  |  直到 7 年前
        1
  •  1
  •   Luiz Eduardo    3 年前

    您有一些解决方法,首先,您需要替换空间。其次,查看官方文档,您可以发送一个json,并填写字段,如下示例:

    官方文件 https://confluence.atlassian.com/jirasoftwareserver/search-syntax-for-text-fields-939938747.html

    在运行某些东西之前,请访问文档!

    curl --request POST \
      --url 'https://your-domain.atlassian.net/rest/api/2/issue' \
      --user 'email@example.com:<api_token>' \
      --header 'Accept: application/json' \
      --header 'Content-Type: application/json' \
      --data '{
      "update": {
        "worklog": [
          {
            "add": {
              "timeSpent": "60m",
              "started": "2019-07-05T11:05:00.000+0000"
            }
          }
        ]
      },
      "fields": {
        "summary": "Main order flow broken",
        "parent": {
          "key": "PROJ-123"
        },
        "issuetype": {
          "id": "10000"
        },
        "components": [
          {
            "id": "10000"
          }
        ],
        "customfield_20000": "06/Jul/19 3:25 PM",
        "customfield_40000": "Occurs on all orders",
        "customfield_70000": [
          "jira-administrators",
          "jira-software-users"
        ],
        "project": {
          "id": "10000"
        },
        "description": "Order entry fails when selecting supplier.",
        "reporter": {
          "id": "5b10a2844c20165700ede21g"
        },
        "fixVersions": [
          {
            "id": "10001"
          }
        ],
        "customfield_10000": "09/Jun/19",
        "priority": {
          "id": "20000"
        },
        "labels": [
          "bugfix",
          "blitz_test"
        ],
        "timetracking": {
          "remainingEstimate": "5",
          "originalEstimate": "10"
        },
        "customfield_30000": [
          "10000",
          "10002"
        ],
        "customfield_80000": {
          "value": "red"
        },
        "security": {
          "id": "10000"
        },
        "environment": "UAT",
        "versions": [
          {
            "id": "10000"
          }
        ],
        "duedate": "2019-03-11",
        "customfield_60000": "jira-software-users",
        "customfield_50000": "Could impact day-to-day work.",
        "assignee": {
          "id": "5b109f2e9729b51b54dc274d"
        }
      }
    }'
    
        2
  •  0
  •   Milister    7 年前

    找到解决方案:需要使用转义字符

     curl -XH -u user:pass -X GET -H "Content-Type: application/json" https://mycompany/rest/api/2/search?jql=project='"Technology"+AND+summary~"Check%20O365%20License%20"' | python -m json.tool > 1.json