I'm trying to create(post) an Issue with the rest api using oauth as authentication method. But i always get an Error that I'm not authenticated. GETting Issues works perfectly fine even with an Oauth token. The problem must be the authentication, because as soon as i execute my post-request with basic authentication it works.
My Failing Code:
createTestPromise(oauthKey) {
return new Promise((resolve, reject) => {
const options = {
"url": "http://jira.myCompany.ch/rest/api/2/issue",
"json": true,
"headers": {
"Content-Type": "application/json",
// "Authorization": "Bearer " + oauthKey
},
"auth": { "bearer": oauthKey },
"body": this.data
};
request.post(options, (error, response) => {
if (error) {
reject(error);
} else {
resolve(response);
}
});
});
}
My Working Code:
async getIssues(team, project, oauthKey) {
return new Promise((resolve, reject) => {
const api = "http://jira.myCompany.ch/rest/api/2/search?jql=";
const jql = "project%20%3D%20" + project + "%20AND%20status%20%3D%20Done%20AND%20\"Test%20erstellen\"%20%3D%20\"%20\"%20and%20";
const testLink = "Test-Link%20is%20EMPTY%20and%20cf[10702]%20=%20" + team;
request.get(api + jql + testLink,
{ auth: { bearer: oauthKey } }, function (error, response) {
if (error) {
reject(error);
} else {
resolve(response);
}
});
});
}
Is my Request just wrong or doesn't Jira Support Oauth in Post Statements?
I hope you fixed, we did in python like this https://github.com/atlassian-api/atlassian-python-api/blob/master/atlassian/rest_client.py#L20
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.