Create a work item
Create a work item from the Script Console. Use it as the starting point for scripts that create work items in bulk.
Applies to: Script Master for Jira Β· Cloud
Before you beginβ
- Jira permission: Jira admin, to open the Script Console. Your account also needs Create work items in the target space.
- App permission: an active Script Master license.
Run the scriptβ
- On the Script Console tab, paste the script below into the editor.
- Set
spaceKeyandworkTypeto a space and a work type on your site. - Select Run.
Result: Result shows Jira's answer as JSON. On success, it holds the new work item's id and key. On failure, it holds Jira's errors, for example a required field that is missing.
// Settings
const spaceKey = 'DEMO';
const workType = 'Task';
// https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-post
const payload = {
fields: {
project: { key: spaceKey },
issuetype: { name: workType },
summary: 'Work item created by Script Master',
description: {
type: 'doc',
version: 1,
content: [
{ type: 'paragraph', content: [{ type: 'text', text: 'As a user, I want to...' }] },
],
},
},
};
const response = await requestJira('/rest/api/3/issue', {
method: 'POST',
headers: { Accept: 'application/json', 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
});
return await response.json();
The description uses the Atlassian Document Format, which Jira's REST API version 3 expects for rich text.
Relatedβ
- Bulk clone work items: create many work items from a JQL query.
- Script Console output: how Result shows JSON.
- Use the Snippets library: more Jira REST examples.