Skip to content

Creating a resource returns HTTP 201. #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion lib/jira.js
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,51 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
return;
}

if (response.statusCode !== 200) {
if (response.statusCode / 100 | 0 != 2) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is made in two places. Could you extract it to a helper function like is200ErrorCode?

callback(response.statusCode + ': Unable to connect to JIRA during request.');
return;
}

callback(null, response.body);

});
};

/**
* Deletes the remote links associated with the given issue.
*
* @param issueNumber - The internal id (not the issue key) of the issue
* @param globalId - The global id of the remote link
* @param callback
*/
this.deleteRemoteLink = function deleteRemoteLink(issueNumber, remoteLinkGID, callback) {

var options = {
rejectUnauthorized: this.strictSSL,
uri: this.makeUri('/issue/' + issueNumber + '/remotelink'),
method: 'DELETE',
qs: {globalId: remoteLinkGID},
json: true
};

this.doRequest(options, function(error, response) {

if (error) {
callback(error, null);
return;
}

if (response.statusCode === 404) {
callback('Cannot delete remote link. Invalid issue.');
return;
}

if (response.statusCode === 400) {
callback('Cannot create remote link. ' + response.body.errors.title);
return;
}

if (response.statusCode / 100 | 0 != 2) {
callback(response.statusCode + ': Unable to connect to JIRA during request.');
return;
}
Expand Down