Vscode-restclient: Multi-line variables

Created on 27 Oct 2020  路  3Comments  路  Source: Huachao/vscode-restclient

This might be a very nich茅 request but it also might not be.
I am in a situation where I need to talk to an API that accepts JSON inside of a form-encoded field

POST https://{{apiHost}}/path HTTP/1.1
Host: {{apiHost}}
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache

&value=test
&attributes={ "some attribute here": "some value here" }

It's not the prettiest of API's but it's what we have to work with, the list of attributes can get quite large and I'd like to assign this to a variable with formatted json but put it inside of the form-encoded field like so:

@attributes = { 
  "some attribute here": "some value here",
  "another attribute": 4
}

POST https://{{apiHost}}/path HTTP/1.1
Host: {{apiHost}}
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache

&value=test
&attributes={{attributes}}

I'm not sure what would be the best approach I was either thinking about wrapping it in curly braces or using a similar approach to Powershell where you'd use a backtick to allow a new line for single-line statements.

feature request

Most helpful comment

@Marvin-Brouwer this is not supported yet, but nice suggestion

All 3 comments

@Marvin-Brouwer this is not supported yet, but nice suggestion

I think to support multi line variables, the parser needs to know a start and end-tag that would not be part of the content. Like the three single/double quotes in python.

I've just found myself in a similar need. How about using ``` just like markdown to flag beginning and end of variable content:

@jsonvar = ```
{
    "id": 123, 
    "some": "val"
} 
    ```
Was this page helpful?
0 / 5 - 0 ratings