statusReference

Hi everyone, I am trying to edit a workflow from code using this api https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-workflows/#api-rest-api-3-workflows-update-post. When I build the request body I don’t know what is statusReference data or where I can find it, I have been looking in other apis to get all status data but I am lost. Can someone help me?

1 Like

Hello,

we also try to migrate from the old API to the new bulk create API for workflows and i also stumbled upon this statusReference field. Is it just the ID of the status which is possibly updated with the call? So the status is not created but only updated?
We would also like to know the answer.

OK so i found out by testing the API manually.
The statusReference property is a self defined UUID. The validator demands that this must be a UUID format but it is only unique within the request to match the statuses from statuses property in the payload.
So first you define all statuses, which apparently can be created or updated if you provide their id and generate a UUID for each status in that request as statusReference. Then you use the same statusReference in the payload for workflows.

I have tried with the following request body

{
  "statuses": [
    {
      "description": "This issue is being actively worked on at the moment by the assignee.",
      "name": "In Progress",
      "statusCategory": "IN_PROGRESS",
      "statusReference": "9a734e9b-fcf8-4b23-8574-e35609d42fb3"
    },
    {
      "description": "",
      "name": "To Do",
      "statusCategory": "TODO",
      "statusReference": "bf3a1e68-05b5-4627-ab98-00dab578a121"
    },
    {
      "description": "",
      "name": "Done",
      "statusCategory": "DONE",
      "statusReference": "21f41c0b-1fb2-4738-afb2-caeea08b843a"
    },
    {
      "description": "This was auto-generated by Jira Service Management during workflow import",
      "name": "Review",
      "statusCategory": "TODO",
      "statusReference": "de1746f0-c8c6-482f-9b25-f88bc9cd9c9a"
    }
  ],
  "workflows": [
    {
      "id": "314a3d8e-1f32-480f-ae46-d44ccf30703b",
      "statuses": [
        {
          "properties": {
            "jira.issue.editable": "true",
            "issueEditable": true
          },
          "statusReference": "9a734e9b-fcf8-4b23-8574-e35609d42fb3"
        },
        {
          "properties": {
            "jira.issue.editable": "true",
            "issueEditable": true
          },
          "statusReference": "bf3a1e68-05b5-4627-ab98-00dab578a121"
        },
        {
          "properties": {
            "jira.issue.editable": "true",
            "issueEditable": true
          },
          "statusReference": "21f41c0b-1fb2-4738-afb2-caeea08b843a"
        },
        {
          "properties": {
            "jira.issue.editable": "true",
            "issueEditable": true
          },
          "statusReference": "de1746f0-c8c6-482f-9b25-f88bc9cd9c9a"
        }
      ],
      "transitions": [
        {
          "id": "1",
          "name": "Create",
          "description": "",
          "from": [],
          "to": {
            "statusReference": "bf3a1e68-05b5-4627-ab98-00dab578a121"
          },
          "type": "initial",
          "properties": {
            "jira.issue.editable": "true",
            "jira.i18n.title": "common.forms.create",
            "issueEditable": true
          },
          "validators": [
            {
              "ruleKey": "forge:expression-validator"
            }
          ]
        },
        {
          "id": "11",
          "name": "To Do",
          "description": "",
          "from": [],
          "to": {
            "statusReference": "bf3a1e68-05b5-4627-ab98-00dab578a121"
          },
          "type": "global",
          "properties": {
            "jira.issue.editable": "true",
            "jira.i18n.title": "gh.workflow.preset.todo",
            "issueEditable": true
          },
          "validators": [
            {
              "ruleKey": "forge:expression-validator"
            }
          ]
        },
        {
          "id": "21",
          "name": "In Progress",
          "description": "",
          "from": [],
          "to": {
            "statusReference": "9a734e9b-fcf8-4b23-8574-e35609d42fb3"
          },
          "type": "global",
          "properties": {
            "jira.issue.editable": "true",
            "jira.i18n.title": "gh.workflow.preset.inprogress",
            "issueEditable": true
          },
          "validators": [
            {
              "ruleKey": "forge:expression-validator"
            }
          ]
        },
        {
          "id": "31",
          "name": "Done",
          "description": "",
          "from": [],
          "to": {
            "statusReference": "21f41c0b-1fb2-4738-afb2-caeea08b843a"
          },
          "type": "global",
          "properties": {
            "jira.issue.editable": "true",
            "jira.i18n.title": "gh.workflow.preset.done",
            "issueEditable": true
          },
          "validators": [
            {
              "ruleKey": "forge:expression-validator"
            }
          ]
        },
        {
          "id": "41",
          "name": "review",
          "description": "",
          "from": [
            "10000"
          ],
          "to": {
            "statusReference": "de1746f0-c8c6-482f-9b25-f88bc9cd9c9a"
          },
          "type": "directed",
          "properties": {
            "jira.issue.editable": "true",
            "issueEditable": true
          },
          "validators": [
            {
              "ruleKey": "forge:expression-validator"
            }
          ]
        },
        {
          "id": "51",
          "name": "again",
          "description": "",
          "from": [
            "10008"
          ],
          "to": {
            "statusReference": "de1746f0-c8c6-482f-9b25-f88bc9cd9c9a"
          },
          "type": "directed",
          "properties": {
            "jira.issue.editable": "true",
            "issueEditable": true
          },
          "validators": [
            {
              "ruleKey": "forge:expression-validator"
            }
          ]
        },
        {
          "id": "61",
          "name": "in progress review",
          "description": "",
          "from": [
            "10008"
          ],
          "to": {
            "statusReference": "9a734e9b-fcf8-4b23-8574-e35609d42fb3"
          },
          "type": "directed",
          "properties": {
            "jira.issue.editable": "true",
            "issueEditable": true
          },
          "validators": [
            {
              "ruleKey": "forge:expression-validator"
            }
          ]
        },
        {
          "id": "81",
          "name": "reject",
          "description": "",
          "from": [
            "10008"
          ],
          "to": {
            "statusReference": "de1746f0-c8c6-482f-9b25-f88bc9cd9c9a"
          },
          "type": "directed",
          "properties": {
            "jira.issue.editable": "true",
            "issueEditable": true
          },
          "validators": [
            {
              "ruleKey": "forge:expression-validator"
            }
          ]
        }
      ],
      "version": {
        "id": "9d1c7a68-efb6-438f-b17d-2c9ae696dbac",
        "versionNumber": 2
      }
    }
  ]
}

and I am get the following message { "errorMessages": [ "Invalid request payload. Refer to the REST API documentation and try again." ] }
Am I making any mistakes?