diff --git a/main.go b/main.go index e6852ed..0c386b2 100644 --- a/main.go +++ b/main.go @@ -50,7 +50,7 @@ Examples: args := os.Args[l:] al := len(args) // Requested url/web resource - resource := args[al - 1] + resource := args[al-1] // http client used for PUT, PATCH, DELETE client := &http.Client{} @@ -96,10 +96,12 @@ Note: Use "" around everything but numbers, also wrap json in '' os.Exit(1) } data := args[0] - res, err := http.Post(resource, "application/json; charset=UTF-8", bytes.NewBufferString(data)) + req, err := http.NewRequest(http.MethodPost, resource, bytes.NewBufferString(data)) if err != nil { log.Fatal(err) } + req.Header.Set("Content-Type", "application/json; charset=UTF-8") + res, err := client.Do(req) defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { @@ -120,7 +122,7 @@ Note: Use "" around everything but numbers, also wrap json in '' os.Exit(1) } data := args[0] - req, err := http.NewRequest(http.MethodPut, resource ,bytes.NewBufferString(data)) + req, err := http.NewRequest(http.MethodPut, resource, bytes.NewBufferString(data)) if err != nil { log.Fatal(err) } @@ -146,7 +148,7 @@ Note: Use "" around everything but numbers, also wrap json in '' os.Exit(1) } data := args[0] - req, err := http.NewRequest(http.MethodPatch, resource ,bytes.NewBufferString(data)) + req, err := http.NewRequest(http.MethodPatch, resource, bytes.NewBufferString(data)) if err != nil { log.Fatal(err) }