Add Jira requirements to test cases when created via API

So you have a test case, e.g. TC-1234 and you want to fetch the linked requirements, is that correct?

If that’s the case, you can use following request:

POST api/v1/testcase/find
[
  { 
    "id": 1234,
    "filter": { "project_id": 1 },
    "idOnly": true,
    "map": {
      "entities": ["testcase", "workitem"],
      "result": "workitem"
    }
  }
]

This will return an array of testcase-workitem mappings and with specifying result: "workitem", the workitem values themselved are already resolved. The response will look something like this:

{
  "meta": {
    "offset": 0,
    "count": 2
  },
  "data": [
    {
      "id": 1234,
      "workitem": {
         "id": 17,
         "is_deleted": false,
         "created_at": "2024-08-14T10:49:49.726Z",
         "created_by": 1201,
         "modified_at": "2024-08-14T10:49:49.726Z",
         "modified_by": 1201,
         "deleted_at": null,
         "deleted_by": null,
         "project_id": 1,
         "integration_id": 1,
         "workitem_api_project_id": "10015",
         "workitem_api_id": "19816",
         "workitem_api_type_id": "10004",
         "workitem_key": "CD-28",
         "workitem_status": "To Do",
         "workitem_status_category": "new",
         "workitem_summary": "My Jira Issue",
         "workitem_integration_type": "jira",
         "workitem_info": null
      }
    }, 
   ....
  ]
}

ETA:
This request does not automatically sync the data from the integration tool. Data stored in the other tool (e.g. Jira) might not be up to date (e.g. status, summary, …). To sync the workitem data, please see this post.