# Basic Authorization for http API check

**URL:** <https://discuss.elastic.co/t/basic-authorization-for-http-api-check/221534>\
**Category:** Beats\
**Tags:** heartbeat\
**Created:** [February 29, 2020, 7:10pm UTC](https://discuss.elastic.co/t/basic-authorization-for-http-api-check/221534 "2020-02-29T19:10:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![IMagalashvili](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/imagalashvili/32/105557_2.png) [@IMagalashvili](https://discuss.elastic.co/u/IMagalashvili)\
**Post date:** [February 29, 2020, 7:10pm UTC](https://discuss.elastic.co/t/basic-authorization-for-http-api-check/221534/1 "2020-02-29T19:10:34Z")

</div>

Hello, I have API check URL with Basic Authorization:  
curl --location --request GET '[http://xxx.xxx.xxx.xxx:3000/status](http://xxx.xxx.xxx.xxx:3000/status)'   
--header 'Accept: application/json'   
--header 'Content-Type: application/json'   
--header 'Authorization: Basic '  
and response is  
OK

I tried to add heartbeat configuration:

```
- type: http
  schedule: '@every 5s'
  name: "API Check status"
  enabled: true
  hosts: ["http://xxx.xxx.xxx.xxx:3000/status"]
  check.request:
    method: GET
    headers:
    'Accept': 'application/json'
    'Content-Type': 'application/json'
    'Authorization': 'Basic <token>'
  check.response:
    status: 200
    json:
      - description: check status
        condition:
          equals:
            status: ok

```

But I faced with next error:

```
Error

received status code 401 expecting 200

Response Body

Body size is 185B.

<html>
<head><title>401 Authorization Required</title></head>
<body>
<center><h1>401 Authorization Required</h1></center>
<hr><center>openresty/1.15.8.2</center>
</body>
</html>

```

Could you please help me with correct configuration for this Uptime monitor?

---

<div class="post-metadata">

**Author:** ![jsoriano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsoriano/32/27920_2.png) [@jsoriano](https://discuss.elastic.co/u/jsoriano)\
**Post date:** [March 3, 2020, 7:18pm UTC](https://discuss.elastic.co/t/basic-authorization-for-http-api-check/221534/2 "2020-03-03T19:18:53Z")

</div>

Hey @IMagalashvili,

I think that there can be an indentation problem in your config. Please double check that the headers are actually indented inside the headers section, like this:

```auto
 check.request:
    method: GET
    headers:
      'Accept': 'application/json'
      'Content-Type': 'application/json'
      'Authorization': 'Basic <token>'

```

---

<div class="post-metadata">

**Author:** ![IMagalashvili](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/imagalashvili/32/105557_2.png) [@IMagalashvili](https://discuss.elastic.co/u/IMagalashvili)\
**Post date:** [March 4, 2020, 8:15am UTC](https://discuss.elastic.co/t/basic-authorization-for-http-api-check/221534/3 "2020-03-04T08:15:50Z")

</div>

Hi, thank you! It works!

Irakli

---

<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 1, 2020, 8:15am UTC](https://discuss.elastic.co/t/basic-authorization-for-http-api-check/221534/4 "2020-04-01T08:15:55Z")

</div>

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