Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I create issues using REST API nowadays?

Felipe Fernandes
Contributor
April 29, 2025 edited

Hi everyone,

I'm developing a solution that needs to trigger the creation of a work item through the REST API in a team-managed software project.
However, even though I'm an ORG ADMIN, I'm receiving an "Unauthorized" response and can't perform this action using the API token I created specifically for this solution.

Has anyone experienced something similar? Am I missing any additional permissions or specific configurations for team-managed projects?

Thanks in advance for your help!

 


## Code

function onFormSubmit(e) {

  Logger.log(JSON.stringify(e.namedValues));

  const JIRA_API_TOKEN = PropertiesService.getScriptProperties().getProperty('JIRA_API_TOKEN');

  const JIRA_EMAIL = PropertiesService.getScriptProperties().getProperty('JIRA_EMAIL');

  const jiraUrl = "https://gazeus.atlassian.net/rest/api/3/issue";

  const jiraAuth = "Basic " + Utilities.base64Encode(JIRA_EMAIL + ":" + JIRA_API_TOKEN);

  const values = e.namedValues;

  const managerEmail = getFieldValue(values, "Manager Email");

  const managerAccountId = getUserAccountIdByEmail(managerEmail, jiraAuth);

  const payload = buildJiraPayload(values, managerAccountId);

  const options = {

    method: "POST",

    contentType: "application/json",

    headers: { "Authorization": jiraAuth },

    payload: JSON.stringify(payload),

    muteHttpExceptions: true

  };

  const response = UrlFetchApp.fetch(jiraUrl, options);

  Logger.log(`Status: ${response.getResponseCode()}`);

  Logger.log(`Response: ${response.getContentText()}`);

}


## Payload Example: 

```
{
"fields": {
"project": {
"key": "ONBOARDING"
},
"issuetype": {
"id": "11127"
},
"summary": "Onboarding: TESTE João Silva",
"description": "Onboarding automático criado via formulário Google para TESTE João Silva.",
"customfield_12292": "TESTE.jsilva",
"customfield_12281": "2025-05-05",
"customfield_12283": "Unity, Slack",
"customfield_12286": "backend@gazeus.com",
"customfield_12288": "None",
"customfield_12282": {
"value": "Laptop Windows"
},
"customfield_12278": [
{
"value": "Keyboard"
},
{
"value": "Monitor (1 un.)"
}
],
"customfield_12284": [
{
"value": "Network Access: VPN"
}
],
"customfield_12289": [
{
"value": "JIRA"
},
{
"value": "Confluence"
}
],
"customfield_12290": {
"value": "BackEnd Developer"
}
}
}
16:57:35 Informação Status: 401
16:57:35 Informação Response body: {"errorMessages":["You do not have permission to create issues in this project."],"errors":{}}
```

 

2 answers

0 votes
Bert Dombrecht
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 29, 2025 edited
You do not have permission to create issues in this project.

Makes make think you need to check if the reporter has 'Create issues' permission in the target project. Who is the creator of the issue? Perhaps it needs to be defined explicitly?

(An alternative to a solution like this can be to use native Jira features like a public form or an issue collector)

Felipe Fernandes
Contributor
April 29, 2025

The API token was created with my credentials, and I am an ORG administrator, and I am also part of the project users with administrator permissions. In theory, I should have this kind of permission. I don't know why, through the web interface, I can and through the REST API, I can't.

Bert Dombrecht
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 29, 2025

It does look like an authentication issue though. I like to use Postman to break it down and troubleshoot step by step. (Can I get the authentication to work for a simple GET, then try the POST, ...) You could also try to log the jiraAuth string to make sure it is correct...

But I can't really spot your problem I'm afraid... :-)
I hope a community member that has experienced this can provide more insight!

0 votes
Mohamed Benziane
Community Champion
April 29, 2025

Hi,

Can you share your code, it would be easier for the community to see of there is something wrong in it.

When you receive a 401 error you have some error message, can you share those message also

Felipe Fernandes
Contributor
April 29, 2025

Thanks for reply. I've updated the description including the code and a payload example.

Felipe Fernandes
Contributor
April 29, 2025

I was reviewing the documentation and thinking, what do think if I get using the API v2 instead? Should it work better?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
atlassian, jira service management, jsm webinar, ai in jsm, opsgenie integration, incident management, virtual agent, atlassian intelligence, ai-powered service desk, it operations, atlassian learning, service management webinar, team '25 recap

What’s new in Jira Service Management 🤔

Discover how Atlassian is revolutionizing service management with cutting-edge solutions for AI-powered support, HR Service Management, or DevOps connectivity.

Register here ⬇️
AUG Leaders

Atlassian Community Events