# Logstash HTTP output plugin

**URL:** <https://discuss.elastic.co/t/logstash-http-output-plugin/344553>\
**Category:** Logstash\
**Tags:** docker\
**Created:** [October 6, 2023, 9:13pm UTC](https://discuss.elastic.co/t/logstash-http-output-plugin/344553 "2023-10-06T21:13:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohsin106](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohsin106/32/65203_2.png) [@mohsin106](https://discuss.elastic.co/u/mohsin106)\
**Post date:** [October 6, 2023, 9:13pm UTC](https://discuss.elastic.co/t/logstash-http-output-plugin/344553/1 "2023-10-06T21:13:47Z")

</div>

I'm trying to use the HTTP output plugin to send a PUT request to a URL but getting a 400 message, and I can't figure out what I'm messing up.  
I'm using Logstash **v8** running in a Docker container.

I'm able to successfully make a PUT request using Postman App. This is the HTTP code that Postman generates which I'm using to configure the HTTP plugin in Logstash

```auto
PUT /v2/conversation/account/accountid1122/sendMessage HTTP/1.1
Host: endpoint.testing.com
Authorization: my auth code
Content-Type: application/json
Content-Length: 257

{
    "recipients": [
        {
            "phone": "+1234567890",
            "firstName": "Test",
            "lastName": "Test"
        }
    ],
    "locationId": "myLocationID",
    "msg": "API Test!",
    "scheduledAt": null
}

```

My HTTP plugin looks like this:

```auto
http {
       http_method => "put"
       url => "https://endpoint.testing.com/v2/conversation/account/accountid1122/sendMessage"
       headers => {
          "Content-Type" => "application/json"
          "Authorization" => "MyAuthCode"
       }
       message => '{
          "recipients": [
              {
                  "phone": "1234567890",
              }
          ],
          "locationId": "myLocationID",
          "msg": "API Test!!",
          "scheduledAt": null
        }'
    }

```

Logstash is throwing 400 error.

```auto
Encountered non-2xx HTTP code 400 {:response_code=>400, :url=>"https://endpoint.testing.com/v2/conversation/account/accountid1122/sendMessage", :event=>#<LogStash::Event:0x76181d9a>

```

What am I messing up?

---

<div class="post-metadata">

**Author:** ![mohsin106](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohsin106/32/65203_2.png) [@mohsin106](https://discuss.elastic.co/u/mohsin106)\
**Post date:** [October 7, 2023, 8:52pm UTC](https://discuss.elastic.co/t/logstash-http-output-plugin/344553/2 "2023-10-07T20:52:49Z")

</div>

Also, is there a way for me to run the Logstash container with auto-config-reload and debug enabled?

---

<div class="post-metadata">

**Author:** ![mohsin106](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohsin106/32/65203_2.png) [@mohsin106](https://discuss.elastic.co/u/mohsin106)\
**Post date:** [October 8, 2023, 1:31pm UTC](https://discuss.elastic.co/t/logstash-http-output-plugin/344553/3 "2023-10-08T13:31:56Z")

</div>

I got auto-reload and debug working and seeing the following error in the debug logs:

```auto
[2023-10-08T13:20:54,205][DEBUG][org.apache.http.wire][main][1d48ee448c470bd49a6ba581e5729fb431ff04a6a255fc46a83462d071f31493] http-outgoing-0 << "{"code":400,"message":"Empty value for msg field not allowed"}"

```

Not sure why I'm getting that even though my msg field is set to `"msg": "API Test!!"`

---

<div class="post-metadata">

**Author:** ![mohsin106](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohsin106/32/65203_2.png) [@mohsin106](https://discuss.elastic.co/u/mohsin106)\
**Post date:** [October 8, 2023, 1:33pm UTC](https://discuss.elastic.co/t/logstash-http-output-plugin/344553/4 "2023-10-08T13:33:18Z")

</div>

I've also added `format => "message"` in my HTTP output plugin

---

<div class="post-metadata">

**Author:** ![mohsin106](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohsin106/32/65203_2.png) [@mohsin106](https://discuss.elastic.co/u/mohsin106)\
**Post date:** [October 10, 2023, 7:12pm UTC](https://discuss.elastic.co/t/logstash-http-output-plugin/344553/5 "2023-10-10T19:12:26Z")

</div>

Able to figure out the issue. Just needed to remove `"Content-Type" => "application/json"` from the `headers` parameter and set the `content_type` parameter separately.

Working config:

```auto
http {
        http_method => "put"
        url => "https://endpoint.testing.com/v2/conversation/account/accountid1122/sendMessage"
        headers => { "Authorization" => "MyAuthCode"}
        format => "message"
        content_type => "application/json"
        message => '{"msg":"API Test!!","recipients":[{"phone":"%{from}"}],"locationId":"myLocationID","scheduledAt":null}'
      }

```

Otherwise there were `\r\n` characters being inserted into the headers which was throwing off the `put` request.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 7, 2023, 7:12pm UTC](https://discuss.elastic.co/t/logstash-http-output-plugin/344553/6 "2023-11-07T19:12:42Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
