@@ -101,36 +101,31 @@ func flagOptions(
101101 }
102102 }
103103
104- // Only send request body if there's actual data
105- if len (body ) > 0 {
106-
107-
108104 switch bodyType {
109- case MultipartFormEncoded :
110- buf := new (bytes.Buffer )
111- writer := multipart .NewWriter (buf )
112-
113- // For multipart/form-encoded, we need a map structure
114- bodyMap , ok := bodyData .(map [string ]any )
115- if ! ok {
116- return nil , fmt .Errorf ("Cannot send a non-map value to a form-encoded endpoint: %v\n " , bodyData )
117- }
118- if err := apiform .MarshalWithSettings (bodyMap , writer , apiform .FormatComma ); err != nil {
119- return nil , err
120- }
121- if err := writer .Close (); err != nil {
122- return nil , err
123- }
124- options = append (options , option .WithRequestBody (writer .FormDataContentType (), buf ))
125- case ApplicationJSON :
126- bodyBytes , err := json .Marshal (bodyData )
127- if err != nil {
128- return nil , err
129- }
130- options = append (options , option .WithRequestBody ("application/json" , bodyBytes ))
131- default :
132- panic ("Invalid body content type!" )
105+ case MultipartFormEncoded :
106+ buf := new (bytes.Buffer )
107+ writer := multipart .NewWriter (buf )
108+
109+ // For multipart/form-encoded, we need a map structure
110+ bodyMap , ok := bodyData .(map [string ]any )
111+ if ! ok {
112+ return nil , fmt .Errorf ("Cannot send a non-map value to a form-encoded endpoint: %v\n " , bodyData )
113+ }
114+ if err := apiform .MarshalWithSettings (bodyMap , writer , apiform .FormatComma ); err != nil {
115+ return nil , err
116+ }
117+ if err := writer .Close (); err != nil {
118+ return nil , err
119+ }
120+ options = append (options , option .WithRequestBody (writer .FormDataContentType (), buf ))
121+ case ApplicationJSON :
122+ bodyBytes , err := json .Marshal (bodyData )
123+ if err != nil {
124+ return nil , err
133125 }
126+ options = append (options , option .WithRequestBody ("application/json" , bodyBytes ))
127+ default :
128+ panic ("Invalid body content type!" )
134129 }
135130
136131 return options , nil
0 commit comments