06 Feb 2025
12:41 PM
- last edited on
10 Feb 2025
12:27 PM
by
MaciejNeumann
'https://10.0.22.24/api/cluster/v2/tokens' \
-H 'accept: application/json; charset=utf-8' \
-H 'Authorization: Api-Token <afterinstallation-Token> \
-H 'Content-Type: application/json; charset=utf-8' \
-d '{
"expiresIn": {
"unit": "DAYS",
"value": 0
},
"name": "EnvTknMgmt",
"scopes": [
"EnviromentTokenManagement"
]
Results:
{
"error": {
"code": 400,
"message": "Could not map JSON at 'scopes[0]' near line 8 column 5"
}
}
Solved! Go to Solution.
06 Feb 2025 02:35 PM
Also the following does not work:
curl -X 'POST' \
'https://10.0.22.24/api/cluster/v2/environments/66bf6127-7a37-40d9-b687-183cba58c020/tokenManagementT...' \
-H 'accept: application/json; charset=utf-8' \
-H 'Authorization: Api-Token dt0c01.NIUWRR7LOH7K4JZOX27FYYZZ.GMXDP65SGHVXOPEMDWZS2QGLDSPK6JBIPEBFGII75J7ZGMMYUG35KKBT3CN3RWMR' \
-H 'Content-Type: application/json; charset=utf-8' \
-d '{
"expiresIn": {
"unit": "SECONDS",
"value": 3600
},
"name": "Token Management"
}'
This comes with a 403:
{
"error": {
"code": 403,
"message": "Token is missing required scope. Use one of: EnvironmentTokenManagement (\"Token Management\" Token creation for existing environments)"
}
}
07 Feb 2025 01:09 AM
You have typo (EnviromentTokenManagement), it should be EnvironmentTokenManagement for the scope.
For the follow up you are using a Cluster token without the right scope.
Also even if it is just local cluster I would advise against posting tokens publicly.
https://docs.dynatrace.com/managed/shortlink/api-cluster-tokens-create-new#request-body-objects