floralvikings / jira-connector

NodeJS Wrapper for the Jira REST API
http://floralvikings.github.io/jira-connector/
MIT License
373 stars 180 forks source link

Issue With The BuildRequestOptions When calling GetAllprojects() #115

Closed MXM-7 closed 5 years ago

MXM-7 commented 6 years ago

Hello, I was debugging a vscode plugin that is using your lib (By the way thank you for your work on this)

And some user was having issue after connection to list projects : corporate jira tracker was returning error 400 after call to .getAllProjects function. The request was not correct according to the server

So I tried with the following code building the request option my self and bypassing the buildRequestOptions(opts, '', 'GET') function. as follow

this.getAllProjects = function (opts, callback) {

        var options = {
            uri: this.jiraClient.buildURL('/project'),
            method: 'GET',
            json: true,
            followAllRedirects: true
        };

        return this.jiraClient.makeRequest(options, callback);
    };

and like this it's working. Do you have any idea what is the issue with our servers or with the build request function?

Thank for your help on this

MXM-7 commented 6 years ago

It seem that the BuildRequest function return an empty body and empty qs.

Deleting those after calling the build function as follow

    this.getAllProjects = function (opts, callback) {
        var options = this.buildRequestOptions(opts, '', 'GET');

        delete options.body;
        delete options.qs;

        return this.jiraClient.makeRequest(options, callback);
    };

seem to fix the issue

MrRefactoring commented 5 years ago

@MXM-7 , @gioboa good catch. Thanks for your code samples. Updates will get to the library in the next releases.

MrRefactoring commented 5 years ago

Solved in 2.12.0 version