'Intellij Idea HTTP Request Payload Variable

PROBLEM Intellij Idea HTTP-request POST has payload values dependent on an environment. Variables are not substituted when used in a payload as they are in place of path variables, for example.

JSON decoding error: Unrecognized token 'test': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false'); nested exception is com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'test': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: (io.netty.buffer.ByteBufInputStream)

RESEARCH https://www.jetbrains.com/help/idea/http-client-reference.html

http-client.env.json

{
 "LOCAL": {
  "protocol": "http://",
  "host": "localhost",
  "port": ":8000",
  "apiKey": "api-key",
  "username": "[email protected]",
  "password": "password"
  }
}

https://i.imgur.com/OKzE8pP.png

  • Intellij 2021.2.1
  • you can select payload variables from context menu and navigate with Ctrl + click

QUESTION Is there a way to use variables in a payload?



Solution 1:[1]

After playing some time and rereading the exception, I've had a guess to wrap it into double quotes. Now it works:

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Zon