| Description | Get a list of lines of source code |
URL | /api/sources |
| HTTP Method | GET |
| Response Formats | xml | json | txt |
Security | Requires Code Viewer role on the project |
| Use Case | Example Request |
|---|---|
| Get source code of 'org.codehaus.sonar:sonar-plugin-api:org.sonar.api.measures.CoreMetrics' from line 10 to 20 |
[
{
"10":" *",
"11":" * Sonar is distributed in the hope that it will be useful,",
"12":" * but WITHOUT ANY WARRANTY; without even the implied warranty of",
...
}
] |
Parameter | Description | Required | Default Value | Example Value |
|---|---|---|---|---|
resource | id or key of the resource | Yes | None | org.codehaus.sonar:sonar |
from | First line to display | No | None | 10 |
to | Last line to display (inclusive) | No | None | 20 |
color | Highlights code syntax if true. | No | false | true |
| format | Response format can be set through:
If nothing is set, json is used. | No | None | json |