# Send Headers in HTTP post request

**URL:** <https://discuss.elastic.co/t/send-headers-in-http-post-request/80172>\
**Category:** Beats\
**Tags:** heartbeat\
**Created:** [March 27, 2017, 5:37pm UTC](https://discuss.elastic.co/t/send-headers-in-http-post-request/80172 "2017-03-27T17:37:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![suvitt](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@suvitt](https://discuss.elastic.co/u/suvitt)\
**Post date:** [March 27, 2017, 5:37pm UTC](https://discuss.elastic.co/t/send-headers-in-http-post-request/80172/1 "2017-03-27T17:37:07Z")

</div>

Hi All,

I am not able to send additional headers in the http POST request.

yml file

heartbeat.monitors:

- type: http
# List or urls to query
#urls:  
urls: ["[http://localhost:8724/service/XXX/YYY](http://localhost:8724/service/XXX/YYY)"]
# request details:
check.request.method: POST  
check.request.headers: 'soapaction': '/Processes/XXXX'  
check.request.body: 'XXX'
# Configure task schedule
schedule: '@every 10s'

Able to see the body in the request received by the service but the header is not sent.

Any help is appreciated.

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [March 28, 2017, 8:44am UTC](https://discuss.elastic.co/t/send-headers-in-http-post-request/80172/2 "2017-03-28T08:44:16Z")

</div>

Can you try with newline like this?

```auto
heartbeat.monitors:
- type: http
# List or urls to query
  urls: ["http://localhost:8724/service/XXX/YYY"]
  # request details:
  check.request.method: POST
  check.request.headers:
    soapaction: '/Processes/XXXX'
  check.request.body: 'XXX'
  # Configure task schedule
  schedule: '@every 10s'

```

Can you share the debug log from starting heartbeat in foreground with `-e -d '*,config'`?

Did you check with wireshark the header is missing?

---

<div class="post-metadata">

**Author:** ![suvitt](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@suvitt](https://discuss.elastic.co/u/suvitt)\
**Post date:** [March 28, 2017, 8:39pm UTC](https://discuss.elastic.co/t/send-headers-in-http-post-request/80172/3 "2017-03-28T20:39:08Z")

</div>

Hi Steffen,

Thank you. The new line helped fix the issue.

here is the updated Config I used with multiple elements in header defined for URL.

> ```
> #URL :
> urls: ["http://localhost:9394/service/XXX/YYY"]
> # request details:
> check.request.method: POST
> check.request.headers:
> soapaction: '/Processes/XXX'
> content-type: 'text/xml;charset=UTF-8'
> check.request.body: 'XXXXX'
> 
> ```

Is it possible to define multiple URL's and each URL having unique set of additional headers and body? How would we define this.

Thank you.  
Suvitt

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [March 29, 2017, 9:05am UTC](https://discuss.elastic.co/t/send-headers-in-http-post-request/80172/4 "2017-03-29T09:05:06Z")

</div>

this is not possible. You basically want/need to define multiple monitors. Using dynamic reloading feature in heartbeat, you can have multiple json objects with url + headers/body. But note, dynamic reloading as is will change to match reloading functionality in filebeat/metricbeat in the future.

---

<div class="post-metadata">

**Author:** ![suvitt](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@suvitt](https://discuss.elastic.co/u/suvitt)\
**Post date:** [March 30, 2017, 3:36pm UTC](https://discuss.elastic.co/t/send-headers-in-http-post-request/80172/5 "2017-03-30T15:36:57Z")

</div>

Hi Steffen,

Thanks , defining multiple monitors did the trick.

here is the sample I used.

```
heartbeat.monitors:
- type: http
  ##Sample SOAP/HTTP
  urls: ["http://localhost:8724/service/XXX/YYY"]
  check.request.method: POST
  check.request.headers:
    soapaction: '/Processes/XXXX'
	accept-encoding: 'gzip,deflate'
    content-type: 'text/xml;charset=UTF-8'
  check.request.body: '<SOAP message>'
  schedule: '@every 10s'
- type: http
  ##Sample rest api
  urls: ["http://localhost:8725/api/XXX/YYY"]
  check.request.method: POST
  check.request.headers:
    content-type: 'application/json'
    accept-encoding: 'gzip,deflate'
  check.request.body: '<json message>' 
  schedule: '@every 10s'

```

Thanks for the help.

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [March 31, 2017, 12:02pm UTC](https://discuss.elastic.co/t/send-headers-in-http-post-request/80172/6 "2017-03-31T12:02:21Z")

</div>

One more tip: you might want to 'indicate' the different monitoring types for filtering in Kibana (or via Elasticsearch API). In the future you might be able to make use of [this (open ticket)](https://github.com/elastic/beats/issues/3623), but for now using `name` will set the event `type` field to the name configured (to be improved according to [this ticket](https://github.com/elastic/beats/issues/3838))

---

<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:** [April 28, 2017, 12:03pm UTC](https://discuss.elastic.co/t/send-headers-in-http-post-request/80172/7 "2017-04-28T12:03:13Z")

</div>

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