# Monitor API in heartbeat

**URL:** <https://discuss.elastic.co/t/monitor-api-in-heartbeat/216006>\
**Category:** Beats\
**Tags:** heartbeat\
**Created:** [January 22, 2020, 7:59am UTC](https://discuss.elastic.co/t/monitor-api-in-heartbeat/216006 "2020-01-22T07:59:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ollebil](https://avatars.discourse-cdn.com/v4/letter/o/54ee81/32.png) [@ollebil](https://discuss.elastic.co/u/ollebil)\
**Post date:** [January 22, 2020, 7:59am UTC](https://discuss.elastic.co/t/monitor-api-in-heartbeat/216006/1 "2020-01-22T07:59:56Z")

</div>

I'm trying to monitor an API that is behind Azure API management using heartbeat, and I need to submit the API key.

This works: "curl [https://api.blabla.com/service/v1/product/apicall](https://api.blabla.com/service/v1/product/apicall)" -H "Ocp-Apim-Subscription-Key: 1234567890" -i -s"

My heartbeat config is:  
...  
check.request:  
method: "GET"  
headers:  
"'Ocp-Apim-Subscription-Key': '1234567890'"

...

but all i get is ""statusCode": 401, "message": "Access denied due to missing subscription key"  
What am I missing?

---

<div class="post-metadata">

**Author:** ![fallenreaper](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fallenreaper/32/62407_2.png) [@fallenreaper](https://discuss.elastic.co/u/fallenreaper)\
**Post date:** [January 23, 2020, 2:47pm UTC](https://discuss.elastic.co/t/monitor-api-in-heartbeat/216006/2 "2020-01-23T14:47:32Z")

</div>

If you look at the headers section: [https://www.elastic.co/guide/en/beats/heartbeat/current/configuration-heartbeat-options.html](https://www.elastic.co/guide/en/beats/heartbeat/current/configuration-heartbeat-options.html) you will notice that it isnt wrapped in double quotes.

I think you would just want to put `'Ocp-Apim-Subscription-Key': '12345'` on the line after the other header.

It looks like:

```auto
- type: http
  schedule: '@every 5s'
  urls: ["http://localhost:8080/demo/add"]
  check.request:
    method: POST
    headers:
      'Content-Type': 'application/x-www-form-urlencoded'
      'Ocp-Apim-Subscription-Key': '12345' # Maybe?
    # urlencode the body:
    body: "name=first&email=someemail%40someemailprovider.com"
  check.response:
    status: 200
    body:
      - Saved
      - saved

```

---

<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:** [February 20, 2020, 2:47pm UTC](https://discuss.elastic.co/t/monitor-api-in-heartbeat/216006/3 "2020-02-20T14:47:33Z")

</div>

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