Trying to run a simple API GET request for private Gitlab account

I am trying to run a simple API request to GitLab through powershell 5.1. After generating an access token with all privileges using the Web UI I tried to run the following:

invoke-restmethod https://gitlab.com/api/v4/projects?private_token=<my_private_token>/<project_id>

Unfortunately, I get an error:

invoke-restmethod : {"message":"401 Unauthorized"}
At line:1 char:13
+ $response = invoke-restmethod https://gitlab.com/api/v4/projects?priv
...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebReques
   t:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.Pow
   erShell.Commands.InvokeRestMethodCommand

This is strange because running the request for invoke-restmethod https://gitlab.com/api/v4/projects?private_token=<my_private_token> does return valid JSON.

Why am I getting 401 error when I try to access project related information?

Hello, you can do it similar to this example

$headers = @{
  "PRIVATE-TOKEN" = "*****************"
}
$body = @{
  "branch" = "main"
  "commit_message" = "this is a commit"
  "actions" = ""
}
Invoke-RestMethod -Verbose -Header $headers -ContentType 'application/json' -Body ($body|ConvertTo-Json) -Method Post -Uri "https://gitlab.com/api/v4/projects/****/repository/commits"

note: I used PowerShell 7.2.1

When I changed the script like this, I solved the error.
There was an error of Invoke-RestMethod : {“message”:“401 Unauthorized”} when it was number 1, but job success appeared when it was changed to number 2.

1 script

test-install-secure-file:
  stage: test
  variables:
    SECURE_FILES_DOWNLOAD_PATH: './'
  script:
    - echo $CI_JOB_TOKEN
    - $InvalidHeaders = @{'JOB-TOKEN' = $CI_JOB_TOKEN}
    - 'Invoke-RestMethod -Uri https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/secure_files -Method Get -Headers $InvalidHeaders -OutFile .....

2 script

test-install-secure-file:
  stage: test
  variables:
    SECURE_FILES_DOWNLOAD_PATH: './'
  script:
    - echo $CI_JOB_TOKEN
    - $InvalidHeaders = @{'JOB-TOKEN' = $CI_JOB_TOKEN}
    - 'Invoke-RestMethod -Uri $CI_API_V4_URL/projects/$CI_PROJECT_ID/secure_files -Method Get -Headers $InvalidHeaders -OutFile .....