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

How can I get the sessionID from the below response. I have a Post request where I provide the login details to login and want to retrieve the data for the same session using get method. Please can you help how I can do it. I looked into the example 'http://jagdeepjain-msys.blogspot.com/2016/01/an-introduction-to-writing-rest-api.html’ but of no help as I wasn’t able to get the sessionID. #110

Open
PrasannaGumpalli opened this issue Sep 5, 2017 · 2 comments

Comments

@PrasannaGumpalli
Copy link

PrasannaGumpalli commented Sep 5, 2017

{
error: null,
response: IncomingMessage {
_readableState: ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: [Object],
length: 0,
pipes: null,
pipesCount: 0,
flowing: true,
ended: true,
endEmitted: true,
reading: false,
sync: false,
needReadable: false,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null
},
readable: false,
domain: null,
_events: {
end: [Object],
close: [Object],
data: [Function],
error: [Function]
},
_eventsCount: 4,
_maxListeners: undefined,
socket: TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: null,
npnProtocol: undefined,
alpnProtocol: false,
authorized: false,
authorizationError: 'DEPTH_ZERO_SELF_SIGNED_CERT',
encrypted: true,
_events: [Object],
_eventsCount: 10,
connecting: false,
_hadError: false,
_handle: null,
_parent: null,
_host: null,
_readableState: [Object],
readable: false,
domain: null,
_maxListeners: undefined,
_writableState: [Object],
writable: false,
allowHalfOpen: false,
destroyed: true,
_bytesDispatched: 261,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: false,
parser: null,
_httpMessage: [Object],
read: [Function],
_consuming: true,
write: [Function: writeAfterFIN],
_idleNext: null,
_idlePrev: null,
_idleTimeout: -1
},
connection: TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: null,
npnProtocol: undefined,
alpnProtocol: false,
authorized: false,
authorizationError: 'DEPTH_ZERO_SELF_SIGNED_CERT',
encrypted: true,
_events: [Object],
_eventsCount: 10,
connecting: false,
_hadError: false,
_handle: null,
_parent: null,
_host: null,
_readableState: [Object],
readable: false,
domain: null,
_maxListeners: undefined,
_writableState: [Object],
writable: false,
allowHalfOpen: false,
destroyed: true,
_bytesDispatched: 261,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: false,
parser: null,
_httpMessage: [Object],
read: [Function],
_consuming: true,
write: [Function: writeAfterFIN],
_idleNext: null,
_idlePrev: null,
_idleTimeout: -1
},
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: true,
headers: {
server: 'Apache-Coyote/1.1',
'x-powered-by': 'AppServer',
'x-frame-options': 'SAMEORIGIN',
'set-cookie': [Object],
'content-type': 'application/json;charset=ISO-8859-1',
date: 'Tue, 05 Sep 2017 17:20:13 GMT',
connection: 'close'
},
rawHeaders: ['Server',
'Apache-Coyote/1.1',
'X-Powered-By',
'AppServer',
'X-FRAME-OPTIONS',
'SAMEORIGIN',
'Set-Cookie',
'JSESSIONID=A366D49742CEBC650EE9CF544DAC4046.restapp-193394991-1-227831028; Path=/; Secure',
'Set-Cookie',
'JSESSIONID=A366D49742CEBC650EE9CF544DAC4046.restapp-193394991-1-227831028; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/',
'Set-Cookie',
'JSESSIONID=A366D49742CEBC650EE9CF544DAC4046.restapp-193394991-1-227831028; Domain=.walmart.com; Path=/',
'Set-Cookie',
'cookieLanguageType=en; Domain=.walmart.com; Expires=Sat, 02-Jun-2018 17:20:13 GMT; Path=/',
'Set-Cookie',
'DYN_USER_ID=931698641; domain=.walmart.com; expires=Sat, 02-Jun-2018 17:20:13 GMT; path=/; HttpOnly',
'Set-Cookie',
'DYN_USER_CONFIRM=1a2c56847bedfcd098c0f49fd52f5595; domain=.walmart.com; expires=Sat, 02-Jun-2018 17:20:13 GMT; path=/; HttpOnly',
'Set-Cookie',
'SSL_SESSION_ID=6e990a157d26347728505b09d8ce078c; Domain=.walmart.com; Path=/; Secure',
'Set-Cookie',
'wccnt=0; Domain=.walmart.com; Expires=Sat, 02-Jun-2018 17:20:13 GMT; Path=/',
'Content-Type',
'application/json;charset=ISO-8859-1',
'Date',
'Tue, 05 Sep 2017 17:20:13 GMT',
'Connection',
'close'
],
trailers: {},
rawTrailers: [],
upgrade: false,
url: '',
method: null,
statusCode: 200,
statusMessage: 'OK',
client: TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: null,
npnProtocol: undefined,
alpnProtocol: false,
authorized: false,
authorizationError: 'DEPTH_ZERO_SELF_SIGNED_CERT',
encrypted: true,
_events: [Object],
_eventsCount: 10,
connecting: false,
_hadError: false,
_handle: null,
_parent: null,
_host: null,
_readableState: [Object],
readable: false,
domain: null,
_maxListeners: undefined,
_writableState: [Object],
writable: false,
allowHalfOpen: false,
destroyed: true,
_bytesDispatched: 261,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: false,
parser: null,
_httpMessage: [Object],
read: [Function],
_consuming: true,
write: [Function: writeAfterFIN],
_idleNext: null,
_idlePrev: null,
_idleTimeout: -1
},
_consuming: true,
_dumped: false,
req: ClientRequest {
domain: null,
_events: [Object],
_eventsCount: 5,
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
outputSize: 0,
writable: true,
_last: true,
upgrading: false,
chunkedEncoding: false,
shouldKeepAlive: false,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedHeader: [Object],
_contentLength: null,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: [Object],
connection: [Object],
_header: 'POST /rest/user/login?login=abc21@gmail.com&password=qatest HTTP/1.1\r\nhost: 10.117.148.115:8003\r\naccept: application/json\r\ncontent-type: application/json\r\ncontent-length: 56\r\nConnection: close\r\n\r\n',
_headers: [Object],
_headerNames: [Object],
_onPendingData: null,
agent: [Object],
socketPath: undefined,
timeout: undefined,
method: 'POST',
path: '/rest/user/login?login=abc21@gmail.com&password=qatest',
_ended: true,
parser: null,
res: [Circular]
},
request: Request {
domain: null,
_events: [Object],
_eventsCount: 5,
_maxListeners: undefined,
method: 'POST',
body: '{"login":"abc21@gmail.com","password":"qatest"}',
callback: [Function],
readable: true,
writable: true,
explicitMethod: true,
_qs: [Object],
_auth: [Object],
_oauth: [Object],
_multipart: [Object],
_redirect: [Object],
_tunnel: [Object],
headers: [Object],
setHeader: [Function],
hasHeader: [Function],
getHeader: [Function],
removeHeader: [Function],
localAddress: undefined,
pool: {},
dests: [],
__isRequestRequest: true,
_callback: [Function],
uri: [Object],
proxy: null,
tunnel: true,
setHost: true,
originalCookieHeader: undefined,
_jar: [Object],
port: '8003',
host: '10.117.148.115',
path: '/rest/user/login?login=abc21@gmail.com&password=qatest',
_json: true,
httpModule: [Object],
agentClass: [Object],
agent: [Object],
_started: true,
href: 'https://10.117.148.115:8003/rest/user/login?login=abc21@gmail.com&password=qatest',
req: [Object],
ntick: true,
response: [Circular],
originalHost: '10.117.148.115:8003',
originalHostHeaderName: 'host',
responseContent: [Circular],
_destdata: true,
_ended: true,
_callbackCalled: true
},
toJSON: [Function: responseToJSON],
caseless: Caseless {
dict: [Object]
},
read: [Function],
body: {
result: [Object],
status: 'ok',
code: '200'
}
},
body: {
result: {
middleName: '',
lastName: 'QA',
postalcode: 'K1C1T1',
preferredstore: '#3041',
firstName: ’ABC'
},
status: 'ok',
code: '200'
},
jar: RequestJar {
_jar: CookieJar {
enableLooseMode: true,
store: {
idx: {
'10.117.148.115': {
'/': {
JSESSIONID: Cookie = "JSESSIONID=A366D49742CEBC650EE9CF544DAC4046.restapp-193394991-1-227831028; Expires=Thu, 01 Jan 1970 00:00:10 GMT; Path=/; hostOnly=true; aAge=21ms; cAge=22ms"
}
}
}
}
}
},
url: 'https://10.117.148.115:8003/rest/user/login?login=abc21@gmail.com&password=qatest',
responseTime: 621.311586
}

@balamcsd
Copy link

balamcsd commented May 7, 2018

did u find solution to read sessionid and use it in subsequent calls.
I have similar requirement. i am calling rest service using https protocol, communication method is json POST using basic authentication. i have to maintain same session throught. can you please suggest

@balamcsd
Copy link

Please check below link
microsoft/cpprestsdk#753

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