我在尝试使用 SonarQube API 生成
GLOBAL_ANALYSIS_TOKEN
时遇到问题。如果您能提供任何帮助或见解,我将不胜感激。
https://quality-analysis.my-company.io/sonar/api/user_tokens/generate
这是我发送的 JSON 有效负载:
{
"name": "TestingfromAPI",
"login": "[email protected]",
"projectKey": "demo",
"type": "GLOBAL_ANALYSIS_TOKEN",
"expirationDate": "2023-10-30"
}
发送请求后,我收到以下错误消息:
{
"errors": [
{
"msg": "The 'name' parameter is missing"
}
]
}
任何指导将不胜感激。谢谢!
文档没有提及发送参数的内容类型。我假设他们不支持 JSON 作为输入。 您可以尝试使用“x-www-form-urlencoded”形式。
curl -u user:password --data 'name=dummy_token_name&type=GLOBAL_ANALYSIS_TOKEN' -H 'Content-Type: application/x-www-form-urlencoded' http://localhost:9000/api/user_tokens/generate