Closed davewat closed 2 years ago
Facing the same issue, funnily enough when calling elastic apis:
[2019-09-10T18:08:00,312][ERROR][logstash.filters.http ] error during HTTP request {:url=>"http://localhost:9200/_reindex", :code=>400,
:response=>"{\"error\":{\"root_cause\":[{\"type\":\"content_type_header_exception\",\"reason\":\"java.lang.IllegalArgumentException: only one Content-Type header should be provided\"}],\"type\":\"content_type_header_exception\",
\"reason\":\"java.lang.IllegalArgumentException: only one Content-Type header should be provided\",\"caused_by\":{\"type\":\"illegal_argument_exception\",\"reason\":\"only one Content-Type header should be provided\"}},
\"status\":400}"}
Went back to using the old rest filter (https://github.com/lucashenning/logstash-filter-rest) as it doesn't have this issue.
Would love to see a fix for this - possibly if you supply a content-type header, it overwrites the default
Until the body_format config is removed in favor of a pure content-type config, I've submitted a pull request to add a body_format of 'form' to set the content-type header to application/x-www-form-urlencoded. Hopefully it's merged so I don't have to have a custom plugin installed across my fleet of logstash nodes.
+1 to fix this issue
i have the same problem, plugin logstash-filter-http when i maked the docker image so the solution is ?
Any news on this, I think I have hit this bug on the latest version.
When assigning a header, for example: "Content-Type" => "application/x-www-form-urlencoded", filter sends header, but also sends an additional "content-type: text/plain".
This breaks the API call I am attempting to make, as the end-point complains about the dual headers.
This is because the source provides a binary choice between JSON or text as content type. There are hundred of other possibilities, and this restriction severely limits the ability to make HTTP calls.
An improvement would allow any string as a value for body_format, and can still default to text/plain. Will submit a PR.