Closed mawkler closed 1 month ago
Note: transferred from rest.nvim
repository as this has something to do with the parser grammar.
variables in http syntax can be only strings but nothing else, just like environment variables.
If you want to define variable in multi-line form, you can use pre-request script to construct the variable:
@foo=123
# @lang lua
{%
local myobj = {
foo = tonumber(request.variables.get(“foo”)),
bar = “bar”,
}
request.variables.set(“body”, vim.json.encode(myobj))
%}
POST http://localhost
{{body}}
It would be neat if I could divide a JSON variable into multiple lines.
The following request
yields the following
curl
requestAs you can see, only the first line (
{
) of the object in@variable
gets included in the requestExpected result: