List issues with webapi

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Developer Edition Version 8.9 (build 43852)
  • what are you trying to achieve
    Retrieve component key with api/components/search web_api to list issues of a specific source file using api/issues/search.
  • what have you tried so far to achieve this
    With LTS version 7, I used web api to list issues but with LTS version 8 it does not work anymore and I don’t find any new web_api to retreive file component key in this new version.

thank you in advance for your help.

Hi,

The web service api/components/search currently returns the key of each component, as shown in the example:

{
  "paging": {
    "pageIndex": 1,
    "pageSize": 100,
    "total": 1
  },
  "components": [
    {
      "key": "project-key",
      "qualifier": "TRK",
      "name": "Project Name",
      "project": "project-key"
    }
  ]
}

Could you maybe provide an example of the problem you’re facing?

Hi @dmeneses ,

The scenario was simple.
I used api/components/search with parameters project=FIL and q=<source name>. I retrieved the componentKey in the result.
After I called api/issues/search with componentKeys=<value found in previous step> to list all the issues.

But now no way to retrieve the componentKey based on the source name only.

See my previous post I created in bug and I moved in help:WEBAPI GET api/components/search doesn't return file information anymore

For me it is due to this change : https://jira.sonarsource.com/browse/SONAR-13291
But it was initially to remove a feature on UI and finally it has also been removed in Web Api.
Thanks

Ok, so if I understood correctly the problem is that you can no longer search for source code files by name with that web service.

You can use the web service api/components/tree with the parameter q to search for files by name.

Thank you @dmeneses , this is what I need.
I searched in other end points and the solution was just below the my eyes :wink:

Thanks again.

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