SonarCloud Web API


(Sasa Salamon) #1

I’m trying to fetch project badges, but all I am getting is “Project is invalid” svg response, whatever I tried.
Is there anything I’m missing?

Sample:
GET https://MYTOKEN:@sonarcloud.io/api/project_badges/measure?metric=code_smells&project=src


(Mario Delgado) #2

use: /api/components/search_projects?ps=50


(Sasa Salamon) #3

I can search for projects, get project_analysis, etc. - this all works fine.
But I can’t get badges, all I get is SVG saying “Project is invalid”

<svg xmlns="http://www.w3.org/2000/svg" height="20" width="105">
<!-- ERROR -->
<linearGradient id="b" x2="0" y2="100%">
    <stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
    <stop offset="1" stop-opacity=".1"/>
</linearGradient>
<clipPath id="a">
    <rect width="105" height="20" rx="3" fill="#fff"/>
</clipPath>
<g clip-path="url(#a)">
    <rect fill="#e05d44" height="20" width="105"/>
    <rect fill="url(#b)" height="20" width="105"/>
</g>
<g fill="#fff" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11" text-anchor="left">
    <text x="4" y="15" fill="#010101" fill-opacity=".3">Project is invalid</text>
    <text x="4" y="14">Project is invalid</text>
</g>

(Fabrice Bellingard) #4

Is your project public or private?


(Sasa Salamon) #5

Private project


(Nicolas Bontoux) #6

Hi there. Then this might relate to the fact that badges are currently not available on private projects (see related topic).