Can I refer to cookies in IntelliJ's HTTP Client?

已回答

I'm using IntelliJ's HTTP Client to test some API calls. However, in my application I enabled CSRF protection, so with each request I get a X-XSRF-TOKEN cookie that I should pass it as the value of the X-XSRF-TOKEN header.

At the moment, my workflow is the following:

  1. Execute the API
  2. Copy the cookie from .idea/httpRequests/http-client.cookies
  3. Paste the cookie in the variables of my environment
  4. And repeat

Is there a way to reference cookies in a request like we can reference variables? For example something like:

POST http://localhost:8080/api/user
Accept: application/json
Content-Type: application/json
X-Csrf-Token: {{Cookie:X-XSRF-TOKEN}}

{"email": "me@example.org", "password": "my password"}
评论操作 固定链接

For now, there is no possibility of doing it. It will be possible to cover that case after implementing this issue: https://youtrack.jetbrains.com/issue/IDEA-239263

Please see https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications if you're not familiar with YouTrack.

0

请先登录再写评论。