rest-nvim / rest.nvim

A fast Neovim http client written in Lua
GNU General Public License v3.0
1.61k stars 142 forks source link

POST non-json body #242

Closed secana closed 8 months ago

secana commented 1 year ago

Hi, I'm trying to use rest.nvim to POST a non-json body. I need to post an XML snippet but

POST https://some.server
Content-Type: application/xml

<Envelope>
    <command>
        <executable>dir</executable>
    </command>
</Envelope>

I get the error:

E5108: Error executing lua .../.local/share/nvim/lazy/rest.nvim/lua/rest-nvim/init.lua:96: import file /Users/.../Envelope> not found stack traceback: [C]: in function 'error' .../.local/share/nvim/lazy/rest.nvim/lua/rest-nvim/init.lua:96: in function 'splice_body' .../.local/share/nvim/lazy/rest.nvim/lua/rest-nvim/init.lua:164: in function 'run' [string ":lua"]:1: in main chunk

HTML encoding the of the xml did not work either. Any idea how to use nvim.rest with non-json payload?

bennypowers commented 6 months ago

Using release 2.0.1, I got:

POST http://localhost:3333
Content-Type: text/html
Accept: text/html

<rh-card>
  <h2 slot="header">SSR</h2>
</rh-card>
   Error  09:09:57 AM notify.error [rest.nvim] ERROR: The tree-sitter node at the range [0:0 - 5:28] has a syntax error and cannot be parsed
   Error  09:09:57 AM msg_show.lua_error   Rest run Error executing Lua callback: .../share/nvim/lazy/rest.nvim/lua/rest-nvim/parser/init.lua:143: attempt to index local 'document_node' (a nil value)
stack traceback:
    .../share/nvim/lazy/rest.nvim/lua/rest-nvim/parser/init.lua:143: in function 'traverse_variables'
    .../share/nvim/lazy/rest.nvim/lua/rest-nvim/parser/init.lua:434: in function 'parse'
    ...al/share/nvim/lazy/rest.nvim/lua/rest-nvim/functions.lua:61: in function 'exec'
    ...cal/share/nvim/lazy/rest.nvim/lua/rest-nvim/commands.lua:44: in function 'impl'
    ...cal/share/nvim/lazy/rest.nvim/lua/rest-nvim/commands.lua:182: in function <...cal/share/nvim/lazy/rest.nvim/lua/rest-nvim/commands.lua:165>
NTBBloodbath commented 6 months ago

Using release 2.0.1, I got:

POST http://localhost:3333
Content-Type: text/html
Accept: text/html

<rh-card>
  <h2 slot="header">SSR</h2>
</rh-card>
   Error  09:09:57 AM notify.error [rest.nvim] ERROR: The tree-sitter node at the range [0:0 - 5:28] has a syntax error and cannot be parsed
   Error  09:09:57 AM msg_show.lua_error   Rest run Error executing Lua callback: .../share/nvim/lazy/rest.nvim/lua/rest-nvim/parser/init.lua:143: attempt to index local 'document_node' (a nil value)
stack traceback:
  .../share/nvim/lazy/rest.nvim/lua/rest-nvim/parser/init.lua:143: in function 'traverse_variables'
  .../share/nvim/lazy/rest.nvim/lua/rest-nvim/parser/init.lua:434: in function 'parse'
  ...al/share/nvim/lazy/rest.nvim/lua/rest-nvim/functions.lua:61: in function 'exec'
  ...cal/share/nvim/lazy/rest.nvim/lua/rest-nvim/commands.lua:44: in function 'impl'
  ...cal/share/nvim/lazy/rest.nvim/lua/rest-nvim/commands.lua:182: in function <...cal/share/nvim/lazy/rest.nvim/lua/rest-nvim/commands.lua:165>

rest.nvim does not support sending HTML code, this issue was about XML. Please open a separate issue.

bennypowers commented 6 months ago

Using release 2.0.1, I got:

POST http://localhost:3333
Content-Type: text/html
Accept: text/html

<rh-card>
  <h2 slot="header">SSR</h2>
</rh-card>
   Error  09:09:57 AM notify.error [rest.nvim] ERROR: The tree-sitter node at the range [0:0 - 5:28] has a syntax error and cannot be parsed
   Error  09:09:57 AM msg_show.lua_error   Rest run Error executing Lua callback: .../share/nvim/lazy/rest.nvim/lua/rest-nvim/parser/init.lua:143: attempt to index local 'document_node' (a nil value)
stack traceback:
    .../share/nvim/lazy/rest.nvim/lua/rest-nvim/parser/init.lua:143: in function 'traverse_variables'
    .../share/nvim/lazy/rest.nvim/lua/rest-nvim/parser/init.lua:434: in function 'parse'
    ...al/share/nvim/lazy/rest.nvim/lua/rest-nvim/functions.lua:61: in function 'exec'
    ...cal/share/nvim/lazy/rest.nvim/lua/rest-nvim/commands.lua:44: in function 'impl'
    ...cal/share/nvim/lazy/rest.nvim/lua/rest-nvim/commands.lua:182: in function <...cal/share/nvim/lazy/rest.nvim/lua/rest-nvim/commands.lua:165>

rest.nvim does not support sending HTML code, this issue was about XML. Please open a separate issue.

Thank you for taking an interest in my issue

Posted here https://github.com/rest-nvim/rest.nvim/issues/386#issue-2304716274