File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 66 "io"
77 "maps"
88 "net/http"
9+ "net/url"
910 "regexp"
1011 "strings"
1112
@@ -37,7 +38,24 @@ func runHTTPRequest(
3738 if err != nil {
3839 cobra .CheckErr ("Failed to create request" )
3940 }
40- req .Header .Add ("Content-Type" , "application/json" )
41+ req .Header .Set ("Content-Type" , "application/json" )
42+ } else if requestStep .Request .BodyForm != nil {
43+ formValues := url.Values {}
44+ for key , val := range requestStep .Request .BodyForm {
45+ interpolatedVal := InterpolateVariables (val , variables )
46+ formValues .Add (key , interpolatedVal )
47+ }
48+
49+ encodedFormStr := formValues .Encode ()
50+ var err error
51+ req , err = http .NewRequest (requestStep .Request .Method , completeURL ,
52+ strings .NewReader (encodedFormStr ),
53+ )
54+ if err != nil {
55+ cobra .CheckErr ("Failed to create request" )
56+ }
57+
58+ req .Header .Set ("Content-Type" , "application/x-www-form-urlencoded" )
4159 } else {
4260 var err error
4361 req , err = http .NewRequest (requestStep .Request .Method , completeURL , nil )
Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ type HTTPRequest struct {
9797 FullURL string
9898 Headers map [string ]string
9999 BodyJSON map [string ]any
100+ BodyForm map [string ]string
100101
101102 BasicAuth * HTTPBasicAuth
102103}
You can’t perform that action at this time.
0 commit comments