usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
28.13k stars 1.31k forks source link

Unsupported Media Type error on Spring Cloud Bus Refresh #826

Open joseangel1994 opened 1 year ago

joseangel1994 commented 1 year ago

I'm trying to make a POST request to this endpoint: http://localhost:8080/actuator/busrefresh, but I'm getting the following response:

{
  "type": "about:blank",
  "title": "Unsupported Media Type",
  "status": 415,
  "detail": "Content-Type 'application/x-www-form-urlencoded;charset=UTF-8' is not supported.",
  "instance": "/actuator/busrefresh"
}

There is no extra config, auth or headers needed, just the POST request to the endpoint. I have tried with Postman and Insomnia and I get the correct result.

Thanks in advance for your support.

martinsefcik commented 1 year ago

@joseangel1994 What is the value of Content-Type header in case you run this request in Postman or Insomnia ?

joseangel1994 commented 1 year ago

I think there is no Content-Type header in Postman, or at least I have not added it manually Screenshot 2023-10-31 at 08 26 29

martinsefcik commented 1 year ago

@joseangel1994 Check raw request in Postman Console if there is any

martinsefcik commented 1 year ago

@joseangel1994 Probably in Bruno for this request on Body tab you choose Form URL Encoded.

image

You should use No Body (in case no body is required for this request) to be sure no content-type header to be set. Currently this header is set even if no key/value pair is provided if Form URL Encoded body is selected. I'm not sure it is correct Bruno behavior or not. Probably yes, because you intentionally choose such body type.

vaugenwake commented 1 year ago

@joseangel1994 Looks like your API does not support a Content-Type header with a charset provided as well: Content-Type 'application/x-www-form-urlencoded;charset=UTF-8' is not supported.

I would say this is an issue with your API validation and not the Bruno client, it is perfectly valid for a client to provide a charset on the content type headers.

https://www.w3.org/International/articles/http-charset/index

ngerwig725 commented 5 months ago

So I am using No Body and there is no content-length header and I am getting a 415 { "Code": "UnsupportedMediaType", "Message": "Unsupported media type: application/x-www-form-urlencoded" } content-type is being set somewhere