Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Client = require('node-rest-client').Client;
- client = new Client();
- // let's login
- var loginArgs = {
- data: {
- "username": "admin",
- "password": "admin"
- },
- headers: {
- "Content-Type": "application/json"
- }
- };
- client.post("http://localhost:8090/jira/rest/auth/1/session", loginArgs, function(data, response){
- if (response.statusCode == 200) {
- console.log('succesfully logged in, session:', data.session);
- var session = data.session;
- // now let's do some request - for example get our session info
- var searchArgs = {
- headers: {
- cookie: session.name + '=' + session.value, // the session cookie
- "Content-Type": "application/json"
- },
- data: {
- jql: ""
- }
- };
- client.post("http://localhost:8090/jira/rest/api/2/search", searchArgs, function(searchResult, response) {
- console.log('status code:', response.statusCode);
- console.log('search result:', searchResult);
- });
- }
- else {
- throw "Login failed :<";
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement