Creating An Issue In A Sprint Using The JIRA REST API

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

問題

When attempting to create a new issue that is already in a sprint using the REST API, you receive the following error:

"errorMessages":[],"errors":
{"sprint":"Field 'sprint' cannot be set. It is not on the appropriate screen, or unknown."}

This is using a JSON payload similar to the following with the POST /rest/api/2/issue endpoint:

{
    "fields": {
       "project":
       {
          "key": "SP"
       },
       "summary": "Sprint issue test",
       "description": "REST APIs are great.",
       "issuetype": {
          "name": "Bug"
       },
       "sprint": {
			"name": "Sprint 1"
		}
	}
}

原因

The incorrect format is used for the sprint. Since sprints can share names and other features, the back end Sprint ID needs to be used.

ソリューション

  1. Determine the custom field ID of the Sprint custom field. To do so, navigate to ⚙ > Issues > Custom fields and click ⚙ > View for the Sprint custom field. Take a look at your URL, you should see customFieldId=XXXXX or something similar - that is the ID of your Sprint custom field. In the example from the screenshot below, the ID is 10104:
  2. Determine the ID of your Sprint. You can find this by hitting the endpoint /rest/agile/1.0/board/{boardId}/sprint, with your board ID being the value found in your URL under rapidView=. You can also find your board IDs using the endpoint /rest/agile/1.0/board.
  3. Once you have those values, you can assign a sprint value as if it were another custom field, using "customfield_XXXXX": YY, where XXXXX is your custom field ID from step 1, and YY is your sprint ID from step 1.

Here is an example of a correctly formed JSON to create an issue in a Sprint with ID 1, and in the case the custom field ID of the Sprint field is 10104:

{
    "fields": {
       "project":
       {
          "key": "SP"
       },
       "summary": "Sprint issue test",
       "description": "REST APIs are great.",
       "issuetype": {
          "name": "Bug"
       },
       "customfield_10104": 1
	}
}

最終更新日 2022 年 5 月 2 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.