Hello There,
I am using SQ-8.9.6 when I user below api in browser it works
http://sonarqube-server:9000/api/components/search?qualifiers=TRK
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
List of sonarqube projects
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
Regards,
SAM
Colin
(Colin)
August 23, 2022, 8:06am
2
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 ’
{“paging”:{“pageIndex”:1,“pageSize”:100,“total”:3},“components”:[{“key”:“sleroy:reactjs-demo”,“name”:“ReactJSdemo”,“qualifier”:“TRK”,“project”:“sleroy:reactjs-demo”},{“key”:“gitlab-sonar”,“name”:“my-app”,“qualifier”:“TRK”,“project”:“gitlab-sonar_AX8lXT9yjCYHsI0QujFF”},{“key”:“grafana-test”,“name”:“grafana-test”,“qualifier”:“TRK”,“project”:“grafana-test”}]}
can you help what I am doing wrong in first query.
Regards,
SAM
Colin
(Colin)
August 23, 2022, 9:49am
4
You should use the component
query parameter rather than componentKey
1 Like
system
(system)
Closed
August 30, 2022, 9:58am
6
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.