Skip to content

Commit bbc7ee4

Browse files
committed
Operation (incl. restful_operation and (ephemeral) restful_resource) always fallback to set body as JSON regardless of Content-Type
1 parent e594b62 commit bbc7ee4

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

internal/client/client.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,6 @@ func (c *Client) Operation(ctx context.Context, path string, body basetypes.Dyna
266266

267267
if !body.IsNull() {
268268
switch req.Header.Get("Content-Type") {
269-
case "application/json":
270-
b, err := dynamic.ToJSON(body)
271-
if err != nil {
272-
return nil, fmt.Errorf("convert body from dynamic to json: %v", err)
273-
}
274-
275-
req.SetBody(string(b))
276269
case "application/x-www-form-urlencoded":
277270
ov, ok := body.UnderlyingValue().(types.Object)
278271
if !ok {
@@ -287,6 +280,12 @@ func (c *Client) Operation(ctx context.Context, path string, body basetypes.Dyna
287280
m[k] = vs.ValueString()
288281
}
289282
req.SetFormData(m)
283+
default:
284+
b, err := dynamic.ToJSON(body)
285+
if err != nil {
286+
return nil, fmt.Errorf("convert body from dynamic to json: %v", err)
287+
}
288+
req.SetBody(string(b))
290289
}
291290
}
292291

0 commit comments

Comments
 (0)