Use case: Create a Jira Issue
Before you start
- Verify Permissions: Ensure you have permissions to create issues in the linked Jira project. This typically requires a valid Jira user account with issue creation rights.
- Linked Jira Configuration: Confirm that the Unity project is linked to a valid Jira ProjectConfig via a ServerConfig.
- Required Fields: Know the required fields for issue creation (e.g., summary, description, issue type). These may vary depending on the Jira project configuration.
- Jira Project Context: Ensure the Jira Project ID and configuration context are valid and active.
- Prepare Metadata: You may need to retrieve available issue types or fields from the Jira project if your application dynamically builds issue forms.
How do I...?
To create a Jira issue from a Unity project, follow these steps:
- Ensure a Jira Link Exists: Your Unity project must already be linked to a Jira ProjectConfig.
- Prepare the payload for the request: Include fields like summary, description, and issue type in your request payload.
- Use the SDK: Call the
CreateIssueAsyncmethod in the Unity Collaboration SDK with the required properties. - Handle Responses: Ensure your implementation verifies whether the issue was successfully created and handles any errors appropriately.
Example:
var summary = "Issue summary";
var description = "Issue description";
var reporterId = new JiraUserId("Reporter User ID");
var assigneeId = new JiraUserId("Assignee User ID");
var parentId = new JiraIssueId("Parent Issue ID");
var jiraIssueId = await jiraIssueService.CreateIssueAsync(
projectId: projectId,
annotationId: annotationId,
jiraProjectConfigId: jiraProjectConfigId,
issueTypeId: issueTypeId,
summary: summary,
description: description,
reporterUserId: reporterId,
assigneeUserId: assigneeId,
parentIssueId: parentId,
cancellationToken: cancellationToken);
Error Handling
- 400 Bad Request: Invalid input.
- 401 Unauthorized: Authentication required.
- 403 Forbidden: Insufficient permissions.