Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requests templates #1479

Open
1 task done
nebolax opened this issue Feb 14, 2023 · 4 comments
Open
1 task done

Requests templates #1479

nebolax opened this issue Feb 14, 2023 · 4 comments
Labels
enhancement New feature or enhancement new Needs triage. Comments are welcome!

Comments

@nebolax
Copy link

nebolax commented Feb 14, 2023

Checklist

  • I've searched for similar feature requests.

Enhancement request

If I am not mistaken then currently there is no support for templates, right?

I would like to see templates in httpie, so that I don't have to retype same arguments across many requests.

By templates I mean that instead of executing http POST my.api.endpoint/users login=testuser password=testpassword I could just do http login or something along this line.

In more details, I would like to see the abilities to:

  1. Create a template from a command
  2. Edit a template (e.g. http edit login password=newpassword updates the password argument in the template)
  3. Use a template with modifications. For example I have to pass many casual arguments to a group of endpoints (pagination, sorting, apikey, etc.). The idea is to create a template like base = http my.api.endpoint sort=asc page=1 apikey=asdf and then use it for interacting with various endpoints. Like http base /some/endpoint param1=x param2=y

Problem it solves

I am always frustrated when I have to retype arguments / copy-paste requests. Example: I am developing an API of an app and there are a few endpoints:

  1. Login a user
  2. Add some money to the user's account
  3. Check the balance

Currently every time I want to do a loop (login, add some money, check balance) I have to enter the entire commands. With templates this process would be much simpler.

Additional information, screenshots, or code examples

@nebolax nebolax added enhancement New feature or enhancement new Needs triage. Comments are welcome! labels Feb 14, 2023
@lefuturiste
Copy link

I've the exact same problem as you, I've tried to use fish alias but It's a little bit complicated because the order of the element matters, for exemple the place where the http methods is matter. It would be easier if there was a method flag.

@sanredz
Copy link

sanredz commented Mar 1, 2023

We are a group of KTH students who would like to work on this issue!

@lefuturiste
Copy link

We are a group of KTH students who would like to work on this issue!

Well I was ready to investigate but go ahead and contribute!

@sanredz sanredz mentioned this issue Mar 8, 2023
@hookenz
Copy link

hookenz commented Jan 11, 2024

I would like to be able to pass a template file and have http replace all the keys in the template file with the values from the command line. That will work well for nested or complex json.

It would then POST or PUT the resulting output as data to send to the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or enhancement new Needs triage. Comments are welcome!
Projects
None yet
Development

No branches or pull requests

4 participants