0

I know I can use "$@" to get or pass all of the arguments.

However, I'm creating a small utility script to encapsulate HTTPie command.

Here's my code, inside Post file:

#!/bin/bash

clear

http --follow --verbose POST https://$1 Content-Type:application/json "$@"

I register this file as a command. And here's a sample of my command:

Post api.example.com/form/save?key=ContactUs name=John title='How are you doing?'

But the problem is that I want to only send the second and later arguments to HTTPie as JSON arguments, and send the first argument as the URL.

Right now, because I send all of the arguments to HTTPie, I get this request body:

{
    "api.holism.local/form/save?key": "ContactUs",
    "name": "John",
    "title": "How are you doing?"
}

I don't want to send the first argument to HTTPie. How can I do that? How can I send the second and later arguments?

Ali EXE
  • 129
  • 2

0 Answers0