Cant able to get List of Projects from Portfolio

SonarQube Version : 10.1

Through API, Recently I’m not able to get the list of Project Names in Portfolio.

I can able to see the Portfolios List through the following API
curl -u Token: "https://sonarURL/api/views/search?p=1&ps=50&qualifiers=VW

But not able to see the Projects list inside that Portfolio, previously I used to get the list, but not now.
API, I’m using
curl -u Token: "https://sonarURL/api/components/tree?component=PortfolioName&qualifiers=VW&strategy=children

Also tried with below API, but no luck
curl -u Token: “https://sonarURL/api/views/projects_status?portfolio=PortfolioName&ps=50”`;

Can you suggest, whether I’m using correct API or do I need to use any other API ?

Hey there.

You should remove qualifiers=VW from this API call

Then, the list of projects will be returned. Like here:

Hi, thanks for the reply,
but this is not printing the list of projects, instead its printing some html syntax

<!DOCTYPE html>
<html lang="en">

    <meta http-equiv="content-type" content="text/html; charset=UTF-8" charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="apple-touch-icon" href="/apple-touch-icon.png">
    <link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png">
    <link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-60x60.png">
    <link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-72x72.png">

It’s not clear to me if you mean the URL that I linked (which I checked, works) or the URL applied to your own SonarQube instance.

Hi Colin, below command is not working
curl -u sqa_e0: ",
this command is not working, its just printing above mentioned html syntax

/sonarqube/ is specific to the SonarQube instance I linked. Try removing that from your URL.

It seems, issues is not with the command, its something related to the Portfolio security settings.
Because, with the same token following command is working, and printing all the Portfolio Names correctly.
curl -u sqa_key: “

and following command (Which is used to print the Project Names inside the Portfolio) is not working
curl -u sqa_key: “”

Getting below message
{“errors”:[{“msg”:“Insufficient privileges”}]}

Note : I’m an admin for this Sonar, and create token with Admin user only

This is an analysis token – which only allows you to perform analysis. Not perform other Web API calls. You should generate a user token (it will start with squ_)

Super, thanks Colin,
I’ve changed the token and its working fine.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.