# Add body to a request while checking for status of the url in heartbeat

**URL:** <https://discuss.elastic.co/t/add-body-to-a-request-while-checking-for-status-of-the-url-in-heartbeat/194990>\
**Category:** Beats\
**Tags:** heartbeat\
**Created:** [August 13, 2019, 9:09am UTC](https://discuss.elastic.co/t/add-body-to-a-request-while-checking-for-status-of-the-url-in-heartbeat/194990 "2019-08-13T09:09:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tinkerbell](https://avatars.discourse-cdn.com/v4/letter/t/ac91a4/32.png) [@Tinkerbell](https://discuss.elastic.co/u/Tinkerbell)\
**Post date:** [August 13, 2019, 9:09am UTC](https://discuss.elastic.co/t/add-body-to-a-request-while-checking-for-status-of-the-url-in-heartbeat/194990/1 "2019-08-13T09:09:45Z")

</div>

How to add body to a request while checking for status of the url in heartbeat.

Here is my sample from heartbeat.yml

- type: http  
enabled: true  
name: "vtrack"  
urls: [""]  
check.request:  
method: GET  
headers: [  
'Content-Type': 'application/json',  
'sessionId': '',  
'userType': '']  
body: {"data":["XXXXX"],"key":"YYYYY"}  
check.response.status: 200  
schedule: '@every 60s'

Above line throws error that body should be an string and not an object. And moreover how do we add username and password to the url ?

---

<div class="post-metadata">

**Author:** ![Andrew\_Cholakian1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrew_cholakian1/32/3612_2.png) [@Andrew\_Cholakian1](https://discuss.elastic.co/u/Andrew_Cholakian1)\
**Post date:** [August 19, 2019, 4:11pm UTC](https://discuss.elastic.co/t/add-body-to-a-request-while-checking-for-status-of-the-url-in-heartbeat/194990/2 "2019-08-19T16:11:46Z")

</div>

Yes, the error is correct. You'll need to quote the JSON body as a string, perhaps using [YAML multiline strings](https://yaml-multiline.info).

---

<div class="post-metadata">

**Author:** ![Tinkerbell](https://avatars.discourse-cdn.com/v4/letter/t/ac91a4/32.png) [@Tinkerbell](https://discuss.elastic.co/u/Tinkerbell)\
**Post date:** [August 22, 2019, 8:56am UTC](https://discuss.elastic.co/t/add-body-to-a-request-while-checking-for-status-of-the-url-in-heartbeat/194990/3 "2019-08-22T08:56:13Z")

</div>

Thank you. It worked. But still i dont know how to attach username password for the 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:** [September 19, 2019, 8:56am UTC](https://discuss.elastic.co/t/add-body-to-a-request-while-checking-for-status-of-the-url-in-heartbeat/194990/4 "2019-09-19T08:56:17Z")

</div>

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