-2

enter image description hereI want to know how to access session_id in cookie for curl api, i want to get session_id and pass to next api, in postman cookie session_id

CURLOPT_HTTPHEADER => array( 'Accept: application/json', 'Content-Type: application/json', 'Cookie: session_id=be9efc76dc826a6112b9c1788b87e328aeb2f9d0' ),

I tried cookie jar and it was not working fro me

Christian Baumann
  • 3,188
  • 3
  • 20
  • 37
  • @svgta answered you quite well. But if you stick to your approach do the following ... 1). To pass the Cookie value to the next Postman request, you need to create a variable to which you can add the current state of the Cookie. Assuming the variable is called PrevCookie. 2.)Then open the "Test" tab of the request in question, and add the following line: pm.environment.set('PrevCookie', request.headers["cookie"]) 3.)Open the next Postman request tab, and in the Header part of the Cookie variable set this value: {{PrevCookie}} – slaff.bg Dec 27 '22 at 13:33
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Jan 02 '23 at 16:47

1 Answers1

0

API can use sessions. But, it's realy not a good idea to use it when you want to access to it with curl (or postman, or others matters). You need to authenticate on it. Some API accepts direct authentication to each calls (header Authorization with Basic id and password). Somes need to authenticate first on a special endpoints to give you a token.

Using sessions in headers is like hacking an account. Some API knows how to block that.

svgta
  • 343
  • 1
  • 6