参考错误:未定义客户端

时间:2017-04-27 11:03:23

标签: node.js

我正在使用以下代码在jira中创建REST API调用: -

var loginArgs = {

data: {
    "username": "singhharwinder@seasiainfotech.com",
    "password": "Seasia@123"
},
headers: {
    "Content-Type": "application/json"
}

};

client.post(" http://jira.atlassian.com/rest/auth/1/session",

loginArgs,function(data,response){

if (response.statusCode == 200) {
    console.log('succesfully logged in, session:', data.session);

    var session = data.session;
    var searchArgs = {
        headers: {
            cookie: session.name + '=' + session.value,
            "Content-Type": "application/json"
        },
        data: {
            jql: "type=Bug AND status=Closed"
        }
    };

    client.post("http://jira.atlassian.com/rest/api/2/search", searchArgs, function (searchResult, response) {
        console.log('status code:', response.statusCode);
        console.log('search result:', searchResult);
    });
} else {
    throw "Login failed :(";
}

});

它给了我"参考错误:客户端未定义"。 请帮帮我。

0 个答案:

没有答案