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":{}}
```