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:
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?
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.