Sending cookies with postman

318.3k views Asked by At

I read the manual of sending request with cookie with postman:

As the packaged app runs in a sandbox separately from the browser, it can not access cookies set inside the browser. This restriction can also be overcome using the Interceptor extension. Postman routes all requests through the Interceptor, which then uses the browser context to send requests. Cookies set inside the browser are automatically attached to your requests. Read the original blog post on Interceptor.

Once the interceptor is enabled, you can also send cookies from Postman. Just set the "Cookie" header, and the cookie will be sent with the request. You can also get access to cookies that are available when the response is returned. Check out out blog post for more

So I downloaded the interceptor for google chrome, and it enable.

Also, I add the following to postman: Cookie JSESSIONID=daczcz36789

When I look at the network I notice that the Cookie is not sent.

What I do wrong?

8

There are 8 answers

5
xxldoctor On BEST ANSWER

You can enable Interceptor in browser and in Postman separately. For send/recieve cookies you should enable Interceptor in Postman. So if you enable interceptor only in browser - it will not work. Actually you don't need enable Interceptor in browser at all - if you don't want to flood your postman history with unnecessary requests.

0
KRISHNA R On

Even after toggling it did not work. I closed and restarted the browser after adding the postman plugin, logged into the site to generate cookies afresh and then it worked for me.

0
RBT On

Chrome apps including Postman are being deprecated as mentioned here. Now the recommendation is to go for native apps which are not detached from the sandboxed environment of the browser.

Quoting from the feature page:

FEATURES EXCLUSIVE TO THE NATIVE APPS:

COOKIES: The native apps let you work with cookies directly. Unlike the Chrome app, no separate extension (Interceptor) is needed.

BUILT-IN PROXY: The native apps come with a built-in proxy that you

can use to capture network traffic.

RESTRICTED HEADERS: The latest version of the native apps let you send headers like Origin and User-Agent. These are restricted in the Chrome app. DON'T FOLLOW

REDIRECTS OPTION: This option exists in the native apps to prevent requests that return a 300-series response from being automatically redirected. Previously, users needed to use the Interceptor extension to do this in the Chrome app.

MENU BAR: The native apps are not restricted by the Chrome standards for the menu bar.

POSTMAN CONSOLE: The latest version of the native apps has a built-in console, which allows you to view the network request details for API calls.

So once you install the native Postman app from here, you don't have to go looking for additional Chrome extensions like Interceptor. Earlier, Postman Interceptor like apps were an additional requirement if we wanted to check browser cookies. All the cookies were visible in Cookies tab as shown below:

enter image description here

2
lukens On

I was having issues getting this working (on OSX). I'd followed the instructions provided by Postman, and the advice here, and cookies were still not being set.

However, the post above saying "So if you enable interceptor only in browser - it will not work" alerted me to the fact that the interceptor could be enabled in the browser as well as in Postman itself. I thought I'd try switching it on in the browser, to see if that helped, and it did. I then switched it off in the browser, and it still worked.

So, if you are having issues getting it working, I'd suggest trying switching it on in browser at least once, as, for me, this seemed to trigger it into life. I think you will still need it switch on in Postman too.

4
Vaha On

I used the postman chrome extension until it became deprecated. Chrome extension is also less usable and powerful than the native postman application. Hence it became very inconvenient to use the chrome extension.

I have found another approach:

  1. copy any request in chrome/any other browser as a CURL request copy curl request
  2. import to postman copied request import to postman copied request
  3. save imported request in the postman's list
0
GuoX On

You should enable your interceptor extension man manually, it locate in the top-right of your postman window. There are several buttons, find the interceptor button and enable it, then you can send cookies after set Cookie field in your request headers.

0
Fangming On

Enable intercepter in this way

Basically it is a chrome plug in. After installing the extention, you also need to make sure the extention is enabled from chrome side.

enter image description here

0
tryingToLearn On

Based @RBT's answer above, I tried Postman native app and want to give a couple of additional details.

In the latest postman desktop app, you can find the cookies option on the extreme right:

enter image description here

You can see the cookies for your localhost (these cookies are linked with the cookies in your chrome browser, although the app is running natively). Also you can set the cookies for a particular domain too.

enter image description here