HTTP Client file not reading environment variables
I added environment variables as described here https://www.jetbrains.com/help/webstorm/exploring-http-syntax.html#example-working-with-environment-files, but my client file never reads the variables. The run context in the variable does not even show the defined environments, so I can't select any of the defined ones.
WebStorm 2020.1.1
Please sign in to leave a comment.
I also had the same issue using JetBrains Rider. I had an established project and when i came to add a http request file and a http-client-env.json file, the IDE was still unable to find the environment and it did not appear in the "Run with:" setting.
I was however able to get it to work by:
After that, I was able to select the environment.
You may be able to right click the folder they reside in rather than each file but i havent tried that.
So in my case it appeared to be how these files are indexed 🤷♂️
I've also got this problem in recent versions of IDE (IntelliJ IDEA 2021.1 and PyCharm 2021.1).
All of a sudden my requests that I used just a few days ago stopped working.
HTTP client fails with the "Invalid URI because of unsubstituted variable 'host'" message and neither of 3 suggested options works:
The only workaround I found is to move the existing environment file to some other location, create a new environment file and copy the environment file content to the new file.
HI,
I've the same issue. In the past the editor worked well for me.
It's looking like this:
I'm using:
IntelliJ IDEA 2020.1.2 (Ultimate Edition)
Build #IU-201.7846.76, built on June 1, 2020
Licensed to xxx
Subscription is active until November 2, 2020
Runtime version: 11.0.7+10-b765.53 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 10.15.5
GC: ParNew, ConcurrentMarkSweep
Memory: 1979M
Cores: 12
Non-Bundled Plugins: com.intellij.plugins.watcher, com.jetbrains.php, intellij.prettierJS, org.asciidoctor.intellij.asciidoc
But I've multiple variables configured:
In the last week I removed / disabled many plugins (but for sure not the "Http Client"). Not sure if it's related to the issue.
best regards
Matthias
I got a similar issue and it turns out I had a hidden character in my `http-client.env.json` file name.
it was quite annoying to debug
Same here.
I have three *.http files in the same directory. (Let say foo.http and bar.http)
Two of them work as expected the third one does not.
---------
foo.http
GET https://{{url_host}}/{{url_path_prefix}}/foo
---------
bar.http
GET https://{{url_host}}/{{url_path_prefix}}/bar
---------
I could provide the same screenshot.
Error message: Invalid URI because of unsubstituted variable
However the variable autocomplete always works as expected after {{.
PhpStorm 2022.1 EAP
Build #PS-221.5080.66, built on March 24, 2022
Runtime version: 11.0.14.1+1-b2043.17 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.16.14-1-default
After some investigation I managed to get this to work by doing the following:
I think this issue might arise when the `.env files support` plugin is activated. I suspect the plugin is finding `*.env.json` files and setting their type to `.env` files and not `.json`.
Please provide the detailed problem description (what do your environment file and HTTP request look like, what errors can you see namely, etc)
Hey there, i am having the same issue.
I've been using http client request files for quite some time now in a certain project where i've been testing all API end points with them. I have added new variables before and it worked completely fine.
I wanted to add a new variable "refreshToken", but since i changed that variable (might be coincidence in timing), phpstorm won't read http environment var files anymore.
I have my request files in sub folders in the folder 'api-requests'. That folder contains the environment files.
$ ls -tR api-requests/
api-requests/:
auth cards me crash-report transactions accounts http-client.env.json http-client.private.env.json.dist http-client.env.json.dist http-client.private.env.json
api-requests/auth:
set-new-password.http forgot-password.http logout.http login.http login-fails.http refresh-token-fails.http refresh-token.http
etc...
If i click the button "Add Environment File" on top of the editor, a new file will be added directly in the sub directory where the request file is in. When i set up an environment with variables there now (just for testing purposes), they are also not read.
This issue started appearing last week.
After that I even updated phpstorm (was using 2020.1, updated to 2020.2) but that sadly didnt solve the issue
There might be some invalid cache which causes the problem, but i have yet to find it.
Any help would be appreciated, I really liked not having to use postman! :)
PhpStorm 2020.2.2
Build #PS-202.7319.77, built on September 23, 2020
Licensed to XXX
Subscription is active until October 7, 2020
Runtime version: 11.0.8+10-b944.31 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.7.7-100.fc31.x86_64
GC: ParNew, ConcurrentMarkSweep
Memory: 926M
Cores: 8
Registry: run.processes.with.pty=TRUE, debugger.watches.in.variables=false
Non-Bundled Plugins: Key Promoter X, String Manipulation, YAML/Ansible support, codes.rudolph.idea.cfg, com.intellij.ideolog, io.github.qeesung.component.HighlightBracketPair, name.kropp.intellij.makefile, de.espend.idea.php.phpunit, net.king2500.plugins.PhpAdvancedAutoComplete, de.espend.idea.php.toolbox, de.espend.idea.php.annotation, fr.adrienbrault.idea.symfony2plugin
Current Desktop: KDE
Works here, on 2020.2.2. Please check if the same problem happens in a brand new project. If it reoccurs - please share more data or examples of your requests
Try restarting your IDE after setting up the environment file.
It worked for me on Windows with a brand new project.
Broken for me as well as at 2020.2.2 and 2020.2.3.
I have a long-running project with an established `http-client.private.env.json` file in it that has worked fine for ages, but now it fails to load the environments when I go to run the commands.
My set-up is pretty simple — a single directory with a few .http files and a single *env.json file. The directory is not excluded. I'm on latest MacOS.
I've tried:
Seems broken to me. Any ideas?
Update: seems to work now for me. I can't make it break now and unfortunately I don't know what I did to fix it, so I don't know conclusively what it was. It will remain a mystery.
Scott Davey you can send us your IDE logs archive (Help > Collect Logs and Diagnostic Data) via Help | Contact Support or via https://uploads.jetbrains.com/. We'll check if there are any HTTP client related errors.
Dimitry, I've uploaded 2020_10_19_RP6pPUb6HFimewH1 for you.
Thanks! Unfortunately the logs didn't provide any insights on the problem.
I've submitted this as https://youtrack.jetbrains.com/issue/IDEA-253417 for a corresponding team to further look into.
Hi, I added a comment to https://youtrack.jetbrains.com/issue/IDEA-253417 which might be a cause.
I'm having the same issue with 2021.1 EAP 3. As you can see all files are in correct place.
The original problem is still not addressed, only 2 votes so far. It would help if you vote for it & leave your comments there.
Hello,
same issue here.
- JetBrains Rider 2021.3.3
- MAC OS
As the screenshot shows I can't add a http-client.env.json because it is there and, in this case, it contains the unsubstituted variable.
Nor is it found in the Env configuration (default: No Environment).
I would be really nice to get it fixed.
Everything works without unsubstituted variable
Same problem, using IntelliJ IDEA 2021.3.3 (Ultimate Edition) and macOS 11.6.5.
I have .http file located outside of project directory, http-client.env.json and http-client.private.env.json were automatically generated next to it. But when I open it with IntelliJ the environment is ignored. I move all files into project root directory and then it started to work.
I was facing the same issue using WebStorm. The problem in my case was that the "Run Configuration" was missing the environment, even tho it was selected in the http request tab.
It is quite simple to reproduce it. Just create an empty project and a new HTTP client request with a variable.
When I tried to run the request in context, it failed because of a missing variable.
Here the generated configuration missing the environment.
However, once I ran it using the "Run All Requests in File" option, it worked.
And the previous generated configuration had the environment set, allowing me to run the request in context without any issue.
--
WebStorm 2022.1
Build #WS-221.5080.193, built on April 10, 2022
Runtime version: 11.0.14.1+1-b2043.25 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 12.4
Same problem (almost?).
Everything works only if request files (`*.http`) and environment files (`http-client*.json`) are directly in the project root directory. Request files from any sub-directories don't 'see' environments, even if these sub-directories have environment files.
Surprisingly, it sometimes does work well, when all http files are moved to a sub-directory, but only until IDE restart.
--
PhpStorm 2022.2.3
Build #PS-222.4345.15, built on October 5, 2022
Runtime version: 17.0.4.1+7-b469.62 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.10.151-1-manjaro
GC: G1 Young Generation, G1 Old Generation
Memory: 8192M
Cores: 12
Registry:
run.processes.with.pty=TRUE
Non-Bundled Plugins:
com.intellij.ideolog (203.0.30.0)
zielu.gittoolbox (212.9.9)
de.espend.idea.php.annotation (8.2.3)
deno (222.4345.14)
fr.adrienbrault.idea.symfony2plugin (2022.1.235)
ru.adelf.idea.dotenv (2022.2)
Current Desktop: KDE
Could be an another case of IDEA-253417, I think.
However, I was not able to reproduce it on my 2022.2.3 installation, environments work fine despite the files location. Is it also reproducible for you on a fresh new test project?
https://stackoverflow.com/questions/61705887/environment-variables-not-work-for-intellij-idea-http-client#answer-73541114
Thank you Apti Tids, your solution worked 👍👍👍.
This seems like a solid bug that jetbrains still have not addressed in JetBrains Rider 2022.3.2.
I am facing this issue in the latest IntelliJ 2024.2 EAP. Here is the stacktrace for the error:
Unhandled exception in [StandaloneCoroutine{Cancelling}@685081ad, LimitedDispatcher@45ad2c05]
java.lang.IllegalArgumentException: Argument for @NotNull parameter 'value' of com/intellij/httpClient/http/request/run/HttpRequestGlobalContext$HttpClientVariables.set must not be null
at com.intellij.httpClient.http.request.run.HttpRequestGlobalContext$HttpClientVariables.$$$reportNull$$$0(HttpRequestGlobalContext.java)
at com.intellij.httpClient.http.request.run.HttpRequestGlobalContext$HttpClientVariables.set(HttpRequestGlobalContext.java)
at com.intellij.httpClient.http.request.run.js.graalvm.HttpClientGraalVmJsResponseHandler$execute$2$1.invokeSuspend$lambda$4$syncGlobals(HttpClientGraalVmJsResponseHandler.kt:77)
at com.intellij.httpClient.http.request.run.js.graalvm.HttpClientGraalVmJsResponseHandler$execute$2$1.invokeSuspend(HttpClientGraalVmJsResponseHandler.kt:80)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1583)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelled}@685081ad, LimitedDispatcher@45ad2c05]
Hey,
I was not able to reproduce it on the latest 2024.2 EAP build, env vars still work as expected in the HTTP client:
Would it be possible to collect logs (Help > Collect Logs) and submit a new YouTrack request, so the team responsible for the HTTP Client subsystem can take a closer look?
https://youtrack.jetbrains.com/newIssue
Same issue here, recent PyCharm Pro, never occurred before. Andrew's solution above did the trick.
- There was no default JSON filetype association with those environment .json files for some reason (PyCharm suggested “text”).
- Instead of “overriding” the context menu offered to “associate” a filetype in my case.
- After associating, the context menu now offers to “override” the filetype.
- I also had to reopen the HTTP client file.
Permalink (just two comments above now): https://intellij-support.jetbrains.com/hc/en-us/community/posts/360008388599/comments/18550572246802