Kong / insomnia

The open-source, cross-platform API client for GraphQL, REST, WebSockets, SSE and gRPC. With Cloud, Local and Git storage.
https://insomnia.rest
Apache License 2.0
34.66k stars 1.96k forks source link

Can't sent json body that contain Mustache variables #7356

Closed JdKock closed 5 months ago

JdKock commented 5 months ago

Expected Behavior

For the Elasticsearch API I need to send some json body with Mustache variables. Here a simple example:

{
    "script": {
        "lang": "mustache",
        "source": {
            "size": "{{var-limit}}",
            "query": {
                "match_all": {}
            }
        }
    }
}

This should be sent to the API as is. Elasticsearch replaces the variable "var-limit" with the value from params. In Postman this is no problem what is send is: "size": "{{var-limit}}"

Actual Behavior

In Insomnia the mustache variable is trying to be replaced with a value before the request is send to Elasticsearch. There is no variable var-limit so what is now send is: "size": "NaN".

Reproduction Steps

No response

Is there an existing issue for this?

Additional Information

No response

Insomnia Version

9.0.0

What operating system are you using?

macOS

Operating System Version

macOS 14.4.1

Installation method

homebrew

Last Known Working Insomnia version

No response

jackkav commented 5 months ago

I suggest using nunjucks syntax keys raw and endraw to stop it from tokenising your input using something like this. {% raw %}your double braced value goes here {{ dontchangeme }}{% endraw %}

JdKock commented 3 months ago

@jackkav Thanks! This works now with: "size": {% raw}"{{var-limit}}"{% endraw %}

But what do you suggest to do with the following: "tags": {{#toJson}}var-tags{{/toJson}}

This should be sent to the API as is. I have now this but that don't work:

"tags": {% raw %}{{#toJson}}var-tags{{/toJson}}{% endraw %}

With double quotes it works: {% raw %}"{{#toJson}}var-channel{{/toJson}}"{% endraw %} But than I have "" put around it but I don't want these.