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!
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()}`);
}
```
{
"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":{}}
```
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)
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for reply. I've updated the description including the code and a payload example.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was reviewing the documentation and thinking, what do think if I get using the API v2 instead? Should it work better?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Discover how Atlassian is revolutionizing service management with cutting-edge solutions for AI-powered support, HR Service Management, or DevOps connectivity.
Register here ⬇️Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.