From 50dd9ff48352094d0c577b7319f5ca730d1286ef Mon Sep 17 00:00:00 2001 From: Ali Alrahahleh Date: Tue, 10 May 2016 14:36:53 -0700 Subject: [PATCH] add support for POST body --- plugins/inputs/httpjson/httpjson.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/inputs/httpjson/httpjson.go b/plugins/inputs/httpjson/httpjson.go index 6fe4da1e5..819188754 100644 --- a/plugins/inputs/httpjson/httpjson.go +++ b/plugins/inputs/httpjson/httpjson.go @@ -244,8 +244,14 @@ func (h *HttpJson) sendRequest(serverURL string) (string, float64, error) { } // Create + send request + body := data.Encode() + body_attr := data.Get('__body') + if body_attr != "" { + list := strings.Split(data.Encode(), '=') + body = list[1] + } req, err := http.NewRequest(h.Method, requestURL.String(), - strings.NewReader(data.Encode())) + strings.NewReader(body)) if err != nil { return "", -1, err }