Issue Generating GLOBAL_ANALYSIS_TOKEN via SonarQube API - 'name' Parameter Missing

  • which versions are you using : Enterprise Edition Version 9.9.1 (build 69595)
  • how is SonarQube deployed: zip, Docker, Helm : Helm
  • what are you trying to achieve : Generating GLOBAL_ANALYSIS_TOKEN via API
  • what have you tried so far to achieve this : performed several calls via Postman and curl

Hello everyone,

I’m encountering an issue while attempting to generate a GLOBAL_ANALYSIS_TOKEN using the SonarQube API. I’d appreciate any assistance or insights you can offer.

Setup and Configuration

  • Endpoint: https://quality-analysis.my-company.io/sonar/api/user_tokens/generate
  • HTTP Method: POST

Request Payload

Here is the JSON payload I am sending:

{
    "name": "TestingfromAPI",
    "login": "ghassen@my-company.io",
    "projectKey": "demo",
    "type": "GLOBAL_ANALYSIS_TOKEN",
    "expirationDate": "2023-10-30"
}

Error Message

Upon sending the request, I receive the following error message:

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

Questions

  1. Despite specifying the name parameter in the JSON payload, why am I still getting an error stating it’s missing?
  2. Is there any specific formatting or encoding required for the name parameter?
  3. Could there be any version-specific limitations causing this?

Any guidance would be highly appreciated. Thank you!

Hi,

Have you tried this via the UI? The best way to master the API is to perform the desired action via the UI and eavesdrop to see which calls the UI made to accomplish the action.

You may also find this guide helpful.

 
HTH,
Ann