Hello
I'm trying to connect a custom AWS Lambda to execute a POST action to JIRA cloud using this endpoint https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-post. The interesting part is that I can make the same request work in Postman without any issues. Here's the code:
const http = require('https');
return new Promise((resolve, reject) => {
// fire the post action
let post_options = {
host: process.env.jira_domain,
port: '443',
path: '/rest/api/3/issue',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content': 'application/json',
'Authorization': 'BASIC ' + process.env.jira_token,
'Accept': 'application/json'
}
};
console.log("POST Options " + JSON.stringify(post_options));
var post_req = http.request(post_options, (res) => {
res.setEncoding('utf8');
res.on('data', (resBody) => {
// chunks.push(resBody);
resolve(resBody);
});
res.on("error", function (error) {
console.error(error);
});
});
post_req.on('error', (e) => {
console.log("Got error: " + e.message);
reject(e.message);
});
post_req.write(JSON.stringify(jiraPayload));
post_req.end();
});
I've even tried to add as many headers as Postman passes. I have another POST request action to Slack on the same method using the exact pattern, and it works without any issues.
When I copy the Token and add it as `Authorization Basic [token]` in Postman, and copy exactly the same payload, I get a 200 from Jira cloud. However, when this is executed from my Lambda function, I get this error:
INFO {"errorMessages":["You do not have permission to create issues in this project."],"errors":{}}
For testing purposes, I've created the API token with the Admin user of the account, and when I see the permissions for that account under the project I'm trying to create, I can see it listed as admin.
Something I've noticed is that Postman is passing a cookie called atlassian.xsrf.token= that I did not manually set, and my Lambda is for sure not passing.
Here's an example of the payload (data being anonymized within []
{"fields":{"assignee":{"id":"[author_id]"},"description":{"content":[{"content":[{"text":"Hello%2BDavid. Full conversation: https://[slack_domain].slack.com/archives/[channel]/p1684538506882069?thread_ts=[thread_id]&cid=[channel_id]","type":"text"}],"type":"paragraph"}],"type":"doc","version":1},"issuetype":{"id":"10004"},"summary":"Slack created ticket","project":{"id":"10000"},"customfield_10034":[{"accountId":"[account1]"},{"accountId":"[account2]"}]}}
BTW I'm on a free plan, so no Granular Permission level is set, and no Issue type security level allowed either. The bottomline is why the same thing works on Postman?
Any ideas on how to solve this?
Thanks and Regards
Hello, I would suggest you to create a new API token and check the status from AWS. Also make sure you are using user level API token (User account >> manage account >> API token) and not the API token from the org admin page (admin.atlassian.com).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.