vscode-restclient icon indicating copy to clipboard operation
vscode-restclient copied to clipboard

I need to escape variable interpolation

Open ndinev opened this issue 3 years ago • 4 comments

I have a post body that looks like

{ text: "this is my {{NotVariable}}" }

Rest client is showing error "Cannot convert undefined or null to object" because it looking for variable 'NotVariable' However I just want to send {{NotVariable}} instead interpolating this to a variable

How to do fix this behavior?

ndinev avatar Aug 08 '22 09:08 ndinev

@ndinev in my test it works, could you please paste the complete request?

Huachao avatar Aug 19 '22 14:08 Huachao

I'm having the same problem as well, I am trying to send 👇

PATCH http://localhost:5000/api/flows/{{flow_id}}/copy
Content-Type: application/json

{
    "v3.home": "Hi {{person.name}}! There are a few people I recommend you should connect with."
}

Here I actually intend to send {{person.name}} as is (it is not a variable) but the REST Client extension shows an error message.

Screenshot 2023-03-06 221810

vsnthdev avatar Mar 06 '23 16:03 vsnthdev

You can use a file for the body to avoid executing variables

`### Create notification template POST {{baseUrl}}/NotificationTemplate Content-Type: application/json Authorization: Bearer {{token.response.body.access_token}}

<@ ./notification-template-1.model`

and file is

{ "TemplateName": "Template 2", "Description": "Some description", "Template": "Hello {{name}}\r\n You have just won {{value}} dollars!\r\n {{#in_ca}}\r\n Well, {{taxed_value}} dollars, after taxes.\r\n {{\/in_ca}}", "AlternateText": "Alternate", "Subject": "Subject", "IsActive": true }

KresoJ avatar Sep 20 '23 08:09 KresoJ

@KresoJ I tried your solution and it gives the same error. can you confirm that it works for you like that?

The backtick character at the end is that required? Doesn't that mean that it actually sends the <@ ./notification-template-1.model as a string, and not the contents of the file

szilardd avatar Sep 21 '23 10:09 szilardd