Basic Authorization for http API check

Hello, I have API check URL with Basic Authorization:
curl --location --request GET '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?

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:

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

Hi, thank you! It works!

Irakli

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