Hi,
I’m trying to fetch projects assigned to portfolio from SonarCloud using API /portfolio-projects. This seems to work just fine if projects are manually selected into portfolio, but if regex or organization selection is used, API returns no projects. In the response, isSelected seems to be true when project belongs to queried portfolio.
I’ve also tried /portfolios/{portfolioId} API, but that seems to work the same way. Have I misunderstood something or is there some other way to get projects in case if regex is used?
Regard,
Janne
Hi Janne, the /portfolio-projects endpoint only returns manually selected projects. If you need the projects of a portfolio with dynamic project selection (tag/regex/organization) please use the /enterprises/portfolio-computed-projects?portfolioId={portfolioId} endpoint. Here is an example response:
{
"projects": [
{
"projectKey": "project-1",
"branchId": "29f8608b-4ded-422d-b4f8-62aebe7415dd",
"name": "Project 1"
},
{
"projectKey": "project-2",
"branchId": "9adb1d82-0d4d-49fd-bdbc-2b258e8e1931",
"name": "Project 2"
}
],
// true if your user does not have permission to view all
// projects in the portfolio
"hiddenProjects": false,
"page": {
"pageIndex": 1,
"pageSize": 50,
"total": 2
}
}
2 Likes
Hi Daniel,
Thanks for the help, that did the trick! I had completely missed that API.
Best regards,
Janne