通过 SonarQube API 生成 GLOBAL_ANALYSIS_TOKEN 时出现问题 - 'name' 参数丢失

问题描述 投票:0回答:1

我在尝试使用 SonarQube API 生成

GLOBAL_ANALYSIS_TOKEN
时遇到问题。如果您能提供任何帮助或见解,我将不胜感激。

设置和配置

  • SonarQube版本:企业版版本9.9.1(内部版本69595)
  • 终点:
    https://quality-analysis.my-company.io/sonar/api/user_tokens/generate
  • HTTP 方法: POST

请求负载

这是我发送的 JSON 有效负载:

{
    "name": "TestingfromAPI",
    "login": "[email protected]",
    "projectKey": "demo",
    "type": "GLOBAL_ANALYSIS_TOKEN",
    "expirationDate": "2023-10-30"
}

错误信息

发送请求后,我收到以下错误消息:

{
    "errors": [
        {
            "msg": "The 'name' parameter is missing"
        }
    ]
}

问题

  1. 尽管在 JSON 负载中指定了 name 参数,为什么我仍然收到一条错误消息,指出它丢失了?
  2. 名称参数是否需要任何特定的格式或编码?
  3. 是否存在任何特定于版本的限制导致此问题?

任何指导将不胜感激。谢谢!

sonarqube token sonarqube-api
1个回答
0
投票

文档没有提及发送参数的内容类型。我假设他们不支持 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
© www.soinside.com 2019 - 2024. All rights reserved.