HTTP Client not set global variable

Hi.

I have code and  click "Run All Requests in file@

POST {{host}}login
Cache-Control: no-cache
Content-Type: application/json

{
"login": {{users_client_login}},
"password": {{users_client_password}}
}

> {% client.global.set("auth_token", response.body.token); %}

###

GET {{host}}user?api_token={{auth_token}}
Accept: application/json
Cache-Control: no-cache
###

client.global.get("auth_token") - correct value token, but {{auth_token}} is undefined

And var_dump($_GET) in my php file:

['api_token' => '{{auth_token}}']

after the second time I get what was installed the first time

How to send a request with a received token?

p.s. sorry my google translate:)

1
4 comments

I have the same problem. The functionality is pretty useless if you cannot get the received token in your next request

0

The problem is fixed and the fix will be included in IDE version 2020.1: https://youtrack.jetbrains.com/issue/WI-49638.

You can test this using EAP build: http://www.jetbrains.com/phpstorm/eap/

0

```

JetBrains Rider 2023.3.2
Build #RD-233.13135.100, built on December 20, 2023
Licensed to The Quantium Group Pty Ltd / David Shen
Subscription is active until September 23, 2024.
Runtime version: 17.0.9+7-b1087.9 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10.0
.NET Core v7.0.10 x64 (Server GC)
GC: G1 Young Generation, G1 Old Generation
Memory: 4054M
Cores: 20
Registry:
 ide.balloon.shadow.size=0
 editor.config.csharp.support=true
 ide.intellij.laf.enable.animation=true
 ide.experimental.ui=true
Non-Bundled Plugins:
 nsubstitutecomplete-rider (1.11.1)
 com.intellij.ideolog (222.2.0.0)
 fr.socolin.application-insights-debug-log-viewer (1.10.0)
 org.plugin.dot.id (1.5.3)
 org.intellij.plugins.hcl (233.13135.65)
 Abc.MoqComplete.Rider (2023.3.0.1)
 com.mallowigi.idea (23.0.0)
 CyclomaticComplexity (2023.3.0)
 com.intellij.resharper.StructuredLogging (2023.3.0.315-eap04)
 com.intellij.ml.llm (233.13135.103)
 mobi.hsz.idea.gitignore (4.5.2)
 com.intellij.resharper.azure (3.50.0.1740-2023.3)
```

I can reproduce this issue again. I think it started since version 2023. My HTTP client scripts worked until recent updates.

0

There is a new similar report on YouTrack:
https://youtrack.jetbrains.com/issue/IDEA-342243/HTTP-Client-tool-global-variables-arent-storing

 

Although, I was not able to quickly reproduce it on PhpStorm 2023.3.2:

I would recommend to enable a detailed HTTP client logging, reproduce the problem, collect logs (Help > Collect Logs) and submit your own report:
https://youtrack.jetbrains.com/newIssue

To increase the log level, just add the following line to “Help > Diagnostic Tools > Debug Log Settings”:
com.intellij.httpClient

 

0

Please sign in to leave a comment.