Jira REST API keeps returning 401

No matter what I try I keep getting a 401 back when i try calling any endpoint on the Jira API.

I’m using this PS script

$Bytes = [System.Text.Encoding]::Unicode.GetBytes("my@email.addr:token")
$EncodedText = [Convert]::ToBase64String($Bytes)

$Headers = @{
    "Authorization" = "Basic $EncodedText"
    "Content-Type" = "application/json"
}


$Uri = "https://myorg.atlassian.net/rest/api/3/issue/IAD-1281"

Invoke-WebRequest -Uri $Uri -Method Get -Headers $Headers

And i also tried using curl

curl -D- -X GET -H "Authorization: Basic <base64 username:token>" -H "Content-Type: application/json" "https://myorg.atlassian.net/rest/api/3/issue/IAD-1281"

I looked at a lot of posts on this forum about it but nothing really seems to help. The only thing returned by the curl is this.

Basic authentication with passwords is deprecated. For more information, see: https://confluence.atlassian.com/cloud/deprecation-of-basic-authentication-with-passwords-for-jira-and-confluence-apis-972355348.html

But as far as i could find out using basic auth with an api token should work?