Skip to content
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

Not able to retain cookies within multiple API calls #109

Open
ngarg0511 opened this issue Sep 1, 2017 · 1 comment
Open

Not able to retain cookies within multiple API calls #109

ngarg0511 opened this issue Sep 1, 2017 · 1 comment

Comments

@ngarg0511
Copy link

ngarg0511 commented Sep 1, 2017

Hi @dareid,
I am working on chakram framework for API automation. It's a great framework.
I want to retain cookies (or JsessionID) while making multiple calls within APIs.
Here is my piece of code where I am making a post call first and then want to make get call next but I am not able to retain session. Can you please help in identifying what is it that I am doing wrong.

var call = require('chakram');
expect = call.expect;
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

testConfig = require('../config1.json');
login1 = require('../login1.json');
expected = require('./../response.json');
var request = require('request');

describe("User login", function () {
before(function () {
var jar = request.jar();
call.setRequestDefaults({jar: true});

  });
it('checking First Name for Login API', function () {		
    return call.post(testConfig.APP_URL + testConfig.LOGIN_API, undefined, login1).then(function (response, body) {
        
		console.log(response.response.body);
		expect(response.response.body.result.firstName).to.equal(expected.result.firstName);		 
         });

});
it('GETUSERAPI', function () {
return call.get(testConfig.APP_URL+"/rest/user/view").then(function(response, body){
console.log("********");
console.log(response.response.body);
});
});
});

Thanks,
Nidhi

@tyoc213
Copy link

tyoc213 commented Apr 25, 2018

Probably doing chakram.setRequestDefaults({jar: true}); as of this test

chakram.setRequestDefaults({jar: true});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants