You need to make the curl URL request using your root login and the password you assigned, so instead of the --header option with ACCESS-TOKEN field to authenticate, to create the initial token you would need to put the username/password in the URL field, so:
https://root:foobar@mygitlab.domain.com/api/v4/users/42/personal_access_tokens
obviously along with the remaining parameters prior to the url itself, just without the header time.
You will then get results back, like from the docs, showing something like:
{
"id": 3,
"name": "mytoken",
"revoked": false,
"created_at": "2020-10-14T11:58:53.526Z",
"scopes": [
"api"
],
"user_id": 42,
"active": true,
"expires_at": "2020-12-31",
"token": "ggbfKkC4n-Lujy8jwCR2"
}
and you can pull the token from the API reponse and then stop utilising the root login in the URL at this point forward and use the access-token which should have been created under the userid for admin
account.
Remember, until you have an access-token you cannot user the --header field with an access-token. And since you can’t create it via the web interface, then you need to use a username/password in your API requests until that initial access-token exists.
The above url is an example, so you need to change “42” to whatever the userid is of your admin account. And the userid you can get also making an API query, but again, you have to provide username/password to check that as well until you create the access-token.