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

Generate code snippet with file as a body content

Open mickeypearce opened this issue 5 years ago • 1 comments

Hi,

I think It would be nice if "Generate code snippet" would include file path content in generated code, similar to environment variables.

For example: from

POST {{url}} HTTP/1.1
content-type: application/json

< ./request.json

to:

curl --request POST \
  --url http://my.url \
  --header 'content-type: application/json' \
  --data '{"my": "request"}'

(instead of --data '< ./request.json')

@Huachao, thanks, very useful extension. :+1:

mickeypearce avatar Apr 19 '19 14:04 mickeypearce

curl (and of course other targets such as python, java, ...) also have the ability to send a file.

For example for the the following example request

POST https://example.com/comments HTTP/1.1

< demo.xml

the following curl command could be generated which reads the file

curl --request POST --url https://example.com/comments --data @demo.xml

stefanbischof avatar Jun 21 '22 11:06 stefanbischof