Skip to content

Variable replacement in file bodies #1116

Open
@tpluscode

Description

@tpluscode

Problem to solve

I prefer to set the request body from a file to keep IDE's syntax support applicable to the given file type

Unfortunately, the {{variable}} replacement tokens do not work there

Proposal

Given that some file types may use the double brace for its own purposes, I'd suggest a new option which would opt-in to replace {{foobar}} as it would when the body was inline in a .hurl file

Request file:

POST /endpoint
file,body.json;
[Options]
replace-file-variables: true

body.json:

{
  "foo": "{{bar}}"
}

When called like hurl --variable bar=baz, it should replace the {{bar}} token in the JSON file before sending the request.

Might also consider a CLI switch --replace-file-variables

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions