# Create Issue API for Custom Issue Type

**URL:** <https://community.developer.atlassian.com/t/create-issue-api-for-custom-issue-type/74607>\
**Category:** Forge\
**Tags:** issue, issuetypes, jira-cloud\
**Created:** [November 10, 2023, 3:56pm UTC](https://community.developer.atlassian.com/t/create-issue-api-for-custom-issue-type/74607 "2023-11-10T15:56:54Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sushilb](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@sushilb](https://community.developer.atlassian.com/u/sushilb)\
**Post date:** [November 10, 2023, 3:56pm UTC](https://community.developer.atlassian.com/t/create-issue-api-for-custom-issue-type/74607/1 "2023-11-10T15:56:54Z")

</div>

Hi  
We are using Forge platform. We have added new Issue Type and we are trying to create issue using this new Custom Issue Type. The issue create API error out saying “Specify Issue Type”. Have any one tried creating issue with custom issue type through API?

Thanks

---

<div class="post-metadata">

**Author:** ![SushilBhattachan](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@SushilBhattachan](https://community.developer.atlassian.com/u/SushilBhattachan)\
**Post date:** [November 13, 2023, 3:30am UTC](https://community.developer.atlassian.com/t/create-issue-api-for-custom-issue-type/74607/2 "2023-11-13T03:30:11Z")

</div>

Any representative from Atlassian?

---

<div class="post-metadata">

**Author:** ![ianRagudo](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/ianragudo/32/44527_2.png) [@ianRagudo](https://community.developer.atlassian.com/u/ianRagudo)\
**Post date:** [November 13, 2023, 5:43am UTC](https://community.developer.atlassian.com/t/create-issue-api-for-custom-issue-type/74607/4 "2023-11-13T05:43:15Z")

</div>

Hi @sushilb,

I was able to successfully create a new issue using a new issue type I created.

Here are the steps I did in the UI:

1. Created the new issue type in the _Issue Type_ screen
2. Associated the new issue type with an issue type scheme for project with key _TEST_ and id `10000`

To create the issue via API call:

1. To ensure that I can create an issue in the specified project, I called [Get create issue metadata](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-createmeta-get) → `GET /rest/api/3/issue/createmeta?projectKeys=TEST` which gives me a response like this:

```auto
{
    "expand": "projects",
    "projects":
    [
        {
            "self": "https://iragudo.atlassian.net/rest/api/3/project/10000",
            "id": "10000",
            "key": "TEST",
            "name": "Test",
            "avatarUrls":
            {
                "48x48": "https://iragudo.atlassian.net/rest/api/3/universal_avatar/view/type/project/avatar/10413",
                "24x24": "https://iragudo.atlassian.net/rest/api/3/universal_avatar/view/type/project/avatar/10413?size=small",
                "16x16": "https://iragudo.atlassian.net/rest/api/3/universal_avatar/view/type/project/avatar/10413?size=xsmall",
                "32x32": "https://iragudo.atlassian.net/rest/api/3/universal_avatar/view/type/project/avatar/10413?size=medium"
            },
            "issuetypes":
            [
                {
                    "self": "https://iragudo.atlassian.net/rest/api/3/issuetype/10002",
                    "id": "10002",
                    "description": "A small, distinct piece of work.",
                    "iconUrl": "https://iragudo.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10318?size=medium",
                    "name": "Task",
                    "untranslatedName": "Task",
                    "subtask": false
                },
                 ...
                {
                    "self": "https://iragudo.atlassian.net/rest/api/3/issuetype/10016",
                    "id": "10016",
                    "description": "",
                    "iconUrl": "https://iragudo.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10300?size=medium",
                    "name": "Custom Ian Issue Type",
                    "untranslatedName": "Custom Ian Issue Type",
                    "subtask": false
                }
            ]
        }
    ]
}

```

1. Now that I’m sure the issue type is associated with the project, I now call the [Create issue](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-post) API with this body:

```auto
{
  "fields": {
    "description": {
      "content": [
        {
          "content": [
            {
              "text": "This is created via API",
              "type": "text"
            }
          ],
          "type": "paragraph"
        }
      ],
      "type": "doc",
      "version": 1
    },
    "issuetype": {
      "id": "10016"
    },
    "labels": [
      "test"
    ],
    "project": {
      "id": "10000"
    },
    "summary": "API TEST Custom Issue Type"
  },
  "update": {}
}

```

With the above-mentioned steps, I was able to successfully create an issue.

Can you share your _Create issue_ REST API call’s request body so we can verify that the necessary issue type field was supplied?

Hope this helps,  
Ian

---

<div class="post-metadata">

**Author:** ![sushilb](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@sushilb](https://community.developer.atlassian.com/u/sushilb)\
**Post date:** [November 13, 2023, 9:18pm UTC](https://community.developer.atlassian.com/t/create-issue-api-for-custom-issue-type/74607/5 "2023-11-13T21:18:17Z")

</div>

@ianRagudo  
Thanks a lot for your help. Yes, we supplied issuetype Name not id. Do you think issue type name instead of id should work?

---

<div class="post-metadata">

**Author:** ![ianRagudo](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/ianragudo/32/44527_2.png) [@ianRagudo](https://community.developer.atlassian.com/u/ianRagudo)\
**Post date:** [November 13, 2023, 9:56pm UTC](https://community.developer.atlassian.com/t/create-issue-api-for-custom-issue-type/74607/6 "2023-11-13T21:56:24Z")

</div>

Hi @sushilb,

Yes, supplying the issue type `name` will work and the request body will look something like this (same as above but using `name` instead of `id`):

```auto
{
  "fields": {
    ...
    "issuetype": {
      "name": "Custom Ian Issue Type"
    } 
   }
}

```

What does your request body look like?

Ian

---

<div class="post-metadata">

**Author:** ![sushilb](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@sushilb](https://community.developer.atlassian.com/u/sushilb)\
**Post date:** [November 14, 2023, 5:47pm UTC](https://community.developer.atlassian.com/t/create-issue-api-for-custom-issue-type/74607/7 "2023-11-14T17:47:01Z")

</div>

Here is the code

```javascript
const createTestCase = async (testCases = []) => {
    for (let i = 0; i < testCases.length; i++) {
      const currTestCase = testCases[i];
      const testCasesField = {
        project: {
          key: projectKey,
        },
        issuetype: {
          name: "Test Case",
        },
        parent: { key: issueKey },
        summary: `${currTestCase.title}`,
        description: {
          type: "doc",
          version: 1,
          content: [
            {
              content: [
                {
                  type: "text",
                  text: "Test Case",
                  marks: [
                    {
                      type: "strong",
                    },
                  ],
                },
              ],
              type: "paragraph",
            },
            {
              content: [
                {
                  text: currTestCase.testCase,
                  type: "text",
                },
              ],
              type: "paragraph",
            },
          ],
        },
      };

      const createdTestCase = await createIssue(testCasesField);

      console.info(
        `Test Case :: issueKey=${issueKey} Iteration=${i} createdIssue=${JSON.stringify(
          createdTestCase
        )}`
      );
    }
  };

const createIssue = async (issueFields) => {
    const createdIssue = await api
      .asApp()
      .requestJira(route`/rest/api/3/issue`, {
        method: "POST",
        body: JSON.stringify({ fields: issueFields }),
      })
      .then((response) => {
        return response.json();
      });

    return createdIssue;
  };
  await handleGenerateJiraStory();

  return {
    body: "Success",
    statusCode: 200,
  };
};

```

---

<div class="post-metadata">

**Author:** ![sushilb](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@sushilb](https://community.developer.atlassian.com/u/sushilb)\
**Post date:** [November 14, 2023, 5:51pm UTC](https://community.developer.atlassian.com/t/create-issue-api-for-custom-issue-type/74607/8 "2023-11-14T17:51:45Z")

</div>

It gives error saying “Specify Issue Type”. So primarily I think it’s not recognizing the issue type.

---

<div class="post-metadata">

**Author:** ![ianRagudo](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/ianragudo/32/44527_2.png) [@ianRagudo](https://community.developer.atlassian.com/u/ianRagudo)\
**Post date:** [November 14, 2023, 11:03pm UTC](https://community.developer.atlassian.com/t/create-issue-api-for-custom-issue-type/74607/9 "2023-11-14T23:03:42Z")

</div>

Hi @sushilb,

I ran your code snippet (removed the loop but the issue creation logic remains intact) and it works fine for me. Have you tried calling [Get create issue metadata](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-createmeta-get) for your project given your `projectKey`? It is possible that your custom issue type “Test Case” is not associated with the project.

Based on recent verification, supplying the issue type name in [Create issue](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-post) REST API works as expected.

Cheers,  
Ian

---

<div class="post-metadata">

**Author:** ![sushilb](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@sushilb](https://community.developer.atlassian.com/u/sushilb)\
**Post date:** [December 6, 2023, 4:38pm UTC](https://community.developer.atlassian.com/t/create-issue-api-for-custom-issue-type/74607/10 "2023-12-06T16:38:24Z")

</div>

@ianRagudo Yes, we got it working. Thanks for your help, really appreciate it. I think when the project is team managed the global Issue Type does not get propogated and it was not creating it :(. Now we ran into another issue of linking issues. But I will create as separate questions. Thanks again.
