New_code_smells measure not giving correct output while invoking from Sonar search API

Hi, I am trying to invoke below API to fetch “New code smell” from project in shell script:


my project is having total 42 code smells out of which 1 is “new code smell in past 30 days”.
Looking for correct endpoint/way to get this “1” in API response, so that -
“CODE_SMELL” measure gives 42.
“NEW_CODE_SMELL” measure gives 1.

But, Using measure as “code_smell” or “new code_smell” are yielding same output.
Please advise right way to fetch ONLY new code smell


Welcome to the community!

Have you tried this via the UI? The best way to master the API is to perform the desired action via the UI and eavesdrop to see which calls the UI made to accomplish the action.

You may also find this guide helpful.


Hello Ann, thanks for your kind words.
I tried to hit same API vis UI as well , new_code_smell is still giving all code smells count.
As I am trying to find some solution though, would be of great help if you also try to hit new_code_smell measure at your side , would be of grateful.
Thanks & regards,

Hi Abhinav,

You’re saying you make exactly the same call as the web UI does, and you get a different response?


Hello Ann,
Really thank you so much for the hint. I went through above shared link and was able to identify the endpoint being hit for “new code smell”. It’s calling : SonarHost/api/measures/component?additionalFields=metrics&component=ProjectKey&metricKeys=new_code_smells

[link : this guide → How to reverse engineer the Sonar Web API]
basically with this anyone can reverse engineer and identify which endpoint is being hit for particular action.
You Rock!!!

1 Like