[Kibana API] Cannot list rules using Kibana API, successfull response, empty data

Hi all!

I'm having a peculiar problem with Kibana API. I'm writing a powershell script to manage my rules/alerts. Here's the problem:

I want to hit this endpoint /api/alerting/rules/_find
to retrieve list of rules that are currently deployed in the stack. I can easily retrieve it using Dev Console but when I'm trying to execute Invoke-RestMethod with powershell all I'm getting is

{
    "page":  1,
    "total":  0,
    "per_page":  10,
    "data":  [

             ]
}

I have created two API Keys - first as elastic superuser, second as kibana_admin, with no restriction on priveledges and neither gives results.
This is my piece of code:

$headers = @{
    'kbn-xsrf' = 'true'
    'Authorization' = "ApiKey $KibanaAPIKey"
}

$get_get_rules_api_call = "/api/alerting/rules/_find"
Invoke-RestMethod -Method GET -Headers $headers -Uri $https://<kibana_host>:<kibana_port>$get_get_rules_api_call -ContentType "text/json" | ConvertTo-Json

I was also trying with basic authentication, with both elastic superuser and kibana_admin but to no avail. With basic authentication I'm getting unauthorized error.

$Token = [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes("username:password"))

$headers = @{
    'kbn-xsrf' = 'true'
    'Authorization' = "Basic $Token"
}

$get_get_rules_api_call = "/api/alerting/rules/_find"
Invoke-RestMethod -Method GET -Headers $headers -Uri $https://<kibana_host>:<kibana_port>$get_get_rules_api_call -ContentType "text/json" | ConvertTo-Json

Invoke-RestMethod : {"statusCode":401,"error":"Unauthorized","message":"[security_exception\n\tRoot causes:\n\t\tsecurity_exception: unable t
o authenticate user [k\u0000i\u0000b\u0000a\u0000n\u0000a\u0000_\u0000a\u0000p\u0000i\u0000_\u0000c\u0000a\u0000l\u0000l\u0000s\u0000_\u0000u
\u0000s\u0000e\u0000r\u0000] for REST request [/_security/_authenticate]]: unable to authenticate user [k\u0000i\u0000b\u0000a\u0000n\u0000a\
u0000_\u0000a\u0000p\u0000i\u0000_\u0000c\u0000a\u0000l\u0000l\u0000s\u0000_\u0000u\u0000s\u0000e\u0000r\u0000] for REST request [/_security/
_authenticate]"}

Any help would be grealty appreciated