rest.nvim
rest.nvim copied to clipboard
[Bug] Can't recognize the variable in header
The {{TOKEN}} in this case, is parsed as value, instead of variable.
The header should be parsed to
header
name: name
value: value
value: value
value: variable
name: identifier
Same problem, in my case, i tried
in older versions works, but i still i love this package, only is solve this little problem
Same problem, in my case, i tried
in older versions works, but i still i love this package, only is solve this little problem
i find a solution, the problem iss because by some reason does not work when is together "Bearer {{TOKEN}}" i created another env file called ".env.http" selecting this env file using the Telescope rest env selector and storing in this env file:
TOKEN=Bearer ey.......
note that i am using a variable with a content without spaces between the texts(the problem was laravels does not support spaces un the env variables as well)
Finally this works:
GET {{APP_URL}}/api/1.0/apps?per_page=15
Authorization: {{TOKEN}}
Content-Type:application/json
@malisoft that's the solution I am using.... have to replace the whole Authorization value.
Hi, sorry for the delay. Life has been kinda busy and I'm still during exams weeks :/
I'm going to move this issue to the tree-sitter-http repository, as it seems to be a problem with the parser and not with rest.nvim itself and fix it as soon as I have some spare time to work on it.
https://github.com/rest-nvim/tree-sitter-http/issues/29
I created this issue in tree-sitter-http before. No one replied, so I duplicated it here for visibility.
I was having issues with setting the Authentication: Bearer XXXXX header, and it ended up being a problem when three conditions happen at the same time:
- the value contains a space (between
Bearerand the actual token, for example) - the token contains a pipe character "
|" - the header value (concatenating the
Bearerpart and the token) was being made in the request definition
Whenever all happen, setting the header like this won't work:
GET /api/test
host: {{API_BASE_URL}}
Accept: application/json
Authorization: Bearer {{BEARER_TOKEN}}
The value received by the server is just Authorization: Bearer.
BUT, if the env variable already contains the whole value (with the Bearer part), then it works.
Here a snippet of how I'm setting the complete Authorization header value:
POST /api/auth
host: {{API_BASE_URL}}
Content-Type: application/json
{
"email": "[email protected]",
"password": "secret"
}
--{%
local body = context.json_decode(context.result.body)
context.set_env("BEARER_TOKEN", "Bearer " .. body.token)
--%}
This seems to be a tree-sitter-http issue. Closing this due to v3 release.
in older versions works, but i still i love this package, only is solve this little problem