Sonarqube API calls not working with curl

Hello There,

I am using SQ-8.9.6 when I user below api in browser it works


but when I do curl it give me error (port 9001 is internal port which works well with localhost)

curl -X GET ‘http://localhost:9001/api/components/search?qualifiers=TRK
{“error”:{“root_cause”:[{“type”:“illegal_argument_exception”,“reason”:“request [/api/components/search] contains unrecognized parameter: [qualifiers]”}],“type”:“illegal_argument_exception”,“reason”:“request [/api/components/search] contains unrecognized parameter: [qualifiers]”},“status”:400}

this is happening for many other queries and I am not sure which query is correct

My requirement is

  1. List of sonarqube projects
  2. Lines of code per project

I am using below
[api/components/search?qualifiers=TRK ]
[api/measures/component?component=<PROJECT_KEY>&metricKeys=ncloc ]

but it gives same “contains unrecognized parameter” can someone guide what I am missing here


Hey there.

Port 9001 is already being used by Elasticsearch – which you cannot query directly. What happens if you use port 9000?

Hello @Colin
Thanks for the response, I figured out that base url was set that was not allowing query to this localhost , but now I am not able to get response

API call = curl -u admin:XXXXXXXX -X GET ‘http://sonarqube-server:9000/api/measures/component?componentKey=sleroy:reactjs-demo&metricKeys=ncloc

Error: {“errors”:[{“msg”:“The \u0027component\u0027 parameter is missing”}

This query working

curl -u admin:XXXXXXXX -X GET ‘https://sonarqube-server:9000/api/components/search?qualifiers=TRK

can you help what I am doing wrong in first query.


You should use the component query parameter rather than componentKey

1 Like

Thank you Colin

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