diff --git a/examples/postman_echo/hardcode_test.go b/examples/postman_echo/hardcode_test.go index e9dbd4aa..66837d74 100644 --- a/examples/postman_echo/hardcode_test.go +++ b/examples/postman_echo/hardcode_test.go @@ -32,6 +32,12 @@ func TestCaseHardcode(t *testing.T) { WithParams(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}). Validate(). AssertEqual("status_code", 200, "check status code"), + httpboomer.Step("post json data"). + POST("/post"). + WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}). + WithJSON(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}). + Validate(). + AssertEqual("status_code", 200, "check status code"), httpboomer.Step("put request"). PUT("/put"). WithHeaders(map[string]string{"User-Agent": "HttpBoomer", "Content-Type": "text/plain"}). diff --git a/runner.go b/runner.go index 4419619a..f88f6891 100644 --- a/runner.go +++ b/runner.go @@ -59,6 +59,7 @@ func (r *Runner) runStep(step *TStep) error { v = append(v, req.Header(step.Request.Headers)) v = append(v, req.Param(step.Request.Params)) v = append(v, step.Request.Data) + v = append(v, req.BodyJSON(step.Request.JSON)) for cookieName, cookieValue := range step.Request.Cookies { v = append(v, &http.Cookie{