Hi, is it possible to add Jira requirements to test cases when creating them through the API?
Hi!
Yes, it’s possible but not officially supported/documented yet. We might offer an easier way in the future to create/link JIRA issues.
For now, you’d first have to create a “workitem” and then link this workitem to the test case:
- Create workitems representing the Jira issue:
POST /api/v1/workitem/bulk
[
{
"project_id": 1, // testiny project id
"integration_id": 1, // testiny integration id
"workitem_integration_type": "jira", // integration type ("jira" for Jira integrations)
"workitem_api_project_id": "10000", // Jira project id as string (typical values are "100XX")
"workitem_api_type_id": "10004" // The Jira issue type id (from Jira API)
"workitem_api_id": "20658", // The Jira issue id (not the key)
},
...more workitems...
]
// The response is a list of created work items. Work item data (title, status, key, etc..) will be synced when opened in the Testiny app.
- Link workitems to test cases:
POST /api/v1/testcase/mapping/bulk/workitem?op=add_or_update
[
// workitem_id: id of newly created work item from above
// testcase_id: id of testiny testcase to link to
// workitem_type: "REQUIREMENT" when linking to testcases
{
"ids": {"testcase_id": 12345, "workitem_id": 37},
"mapped": {"workitem_type": "REQUIREMENT" }
},
...more work item links...
]
If you don’t know the JIRA project ids or the Jira issue type ids, we also offer an API to fetch that:
## Get available projects for an integration
GET /api/v1/workitem-integration/metadata?integration_id=1
## Get available workitem/issue types for a Jira project
GET /api/v1/workitem-integration/metadata?integration_id=1&workitem_project_ids=10000
I hope this is what you’re looking for.
Please let me know if you have any further questions or need anything else.
Best regards,
Hanna
Hi Hanna, thank you for the reply!
Is there a way for me to fetch the "workitem_api_id"
(and any other relevant values needed) using the issue id provided in the Jira UI, for example using QA-3888
for ...atlassian.net/browse/QA-3888
?
Best regards,
Una Mattý
Testiny does not offer any way to fetch these values, but you can use the JIRA API for that.
For your example, ...atlassian.net/browse/QA-3888
would be ...atlassian.net/rest/api/2/issue/QA-3888
. This returns a JSON with details about the issue. The issue id should be amongst the first lines.
Here’s the JIRA (cloud) docs for this API call: https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issues/#api-rest-api-2-issue-issueidorkey-get
As always, feel free to ask follow up questions if needed.
Best regards,
Hanna
Hey Hanna, thank you this has been a great help.
I have one more question regarding this:
Is there a way to fetch requirements that have already been assigned to a test case? In the case where I have to update the requirement for a particular test case and want to either add another requirement or change the requirement already linked to the test case?
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.
Thank you, this helps a lot!