Get a List of Profiles

DescriptionGet a list of profiles

URL

/api/profiles/list

HTTP MethodGET
Response Formatsjson

Security

None
Available sinceVersion 3.3

Examples

Use Case

Example Request

Get all the profiles

GET http://nemo.sonarsource.org/api/profiles/list?format=json

Get all the java profiles

GET http://nemo.sonarsource.org/api/profiles/list?language=java&format=json

Get all the profiles used by project org.codehaus.sonar:sonar

GET http://nemo.sonarsource.org/api/profiles/list?project=org.codehaus.sonar:sonar&format=json

Get the java profile used by project org.codehaus.sonar:sonar

GET http://nemo.sonarsource.org/api/profiles/list?project=org.codehaus.sonar:sonar&language=java&format=json

Response Format

[
  {
    "name":"Sonar way with Findbugs",
    "language":"java",
    "default":false
  },
  {
    "name":"Sonar way",
    "language":"java",
    "default":false
  },
  ...
]

Parameters

Parameter

Description

Required

Default Value

Example Value

language

Profile language

No

None

java

project

Project key or id

No

None

org.codehaus.sonar:sonar

format

Response format can be set through:

  • Parameter format: json
  • Or the 'Accept' property in the HTTP header:
  • Accept:application/json

If nothing is set, json is used.

NoNonejson

Get Coding Rules Activated in a Quality Profile

DescriptionGet the list of coding rules activated in a quality profile

URL

/api/profiles

HTTP MethodGET
Response Formatsjson | xml

Security

None

Examples

Use CaseExample Request
Get all the coding rules activated on the default java quality profile

GET http://nemo.sonarsource.org/api/profiles?language=java

Get all the coding rules activated on the java quality profile 'Common rules'

GET http://nemo.sonarsource.org/api/profiles?language=java&name=Common%20rules

Response Format

[
  {
    "name":"Nemo rules with findbugs",
    "language":"java",
    "parent":"Common rules",
    "default":true,
    "provided":false,
    "rules":[
      {
        "key":"UnnecessaryParentheses",
        "repo":"pmd",
        "severity":"MAJOR"
      },
      {
        "key":"UncommentedEmptyMethod",
        "repo":"pmd","severity":"INFO"
      },
      ...
  }
]

Parameters

Parameter

Description

Required

Default Value

Example Value

language

Project language

Yes

None

java

name

Profile name. If not set, the default profile for the selected language is used.

No

None

Sonar%20way

rule_repositories

Comma-separated list of rules repository keys.

No

None

pmd,findbugs

rule_severities

Comma-separated list of rule severities.
Possible values: BLOCKER | CRITICAL | MAJOR | MINOR | INFO.

No

None

BLOCKER,CRITICAL

format

Response format can be set through:

  • Parameter format: xml | json
  • Or the 'Accept' property in the HTTP header:
    • Accept:text/xml
    • Accept:application/json
If nothing is set, json is used.
NoNonejson

Backup a Quality Profile

DescriptionBackup a quality profile

URL

/api/profiles/backup

HTTP MethodGET
Response Formatsjson | xml
Security

Requires Administer Quality Profiles permission

Available sinceVersion 3.1

Examples

Use CaseExample Request
Backup the default java quality profile

GET http://localhost:9000/api/profiles/backup?language=java

Backup the java quality profile 'Sonar%20way'

GET http://localhost:9000/api/profiles/backup?language=java&name=Sonar%20way

Response Format

{
  "backup":
  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
   <!-- Generated by Sonar -->
   <profile>
     <name>Sonar for Sonar</name>
     <language>java</language>
     <rules>
       <rule>
         <repositoryKey>checkstyle</repositoryKey>
         <key>com.puppycrawl.tools.checkstyle.checks.TodoCommentCheck_1296413157</key>
         <priority>INFO</priority>
         <parameters>
           <parameter>
             <key>format</key><value>TODO</value>
          </parameter>
        </parameters>
      </rule>
      ...
    </rules>
  </profile>"
}

Parameters

Parameter

Description

Required

Default Value

Example Value

language

Project language

Yes

None

java

name

Profile name. If not set, the default profile for the selected language is used.

No

None

Sonar%20way

format

Response format can be set through:

  • Parameter format: xml | json
  • Or the 'Accept' property in the HTTP header:
    • Accept:text/xml
    • Accept:application/json
If nothing is set, json is used.
NoNonejson

Restore a Quality Profile Backup

DescriptionRestore a quality profile backup

URL

/api/profiles/restore

HTTP MethodPOST
Security

Requires Administer Quality Profiles permission

Available sinceVersion 3.1

Examples

Use CaseExample Request
Restore a quality profile from a backup

curl -X POST -u admin:admin -F 'backup=@backup.com' -v http://localhost:9000/api/profiles/restore

Parameters

Parameter

Description

Required

backup

Path to the file containing the backup (HTML format)

Yes

Delete a Quality Profile

DescriptionDelete a quality profile

URL

/api/profiles/destroy

HTTP MethodPOST
Security

Requires Administer Quality Profiles permission

Available sinceVersion 3.3

Examples

Use CaseExample Request
Delete the java quality profile 'Sonar way'

curl -u admin:admin -d "language=java&name=Sonar way" -X POST http://localhost:9000/api/profiles/destroy

Parameters

Parameter

Description

Required

Default ValueExample Value

language

Profile language

Yes

Nonejava
nameProfile nameYesNoneSonar way

Set a Quality Profile as Default

DescriptionDelete a quality profile

URL

/api/profiles/set_as_default

HTTP MethodPOST
Security

Requires Administer Quality Profiles permission

Available sinceVersion 3.3

Examples

Use CaseExample Request
Set the java quality profile 'Sonar way' as default

curl -u admin:admin -d "language=java&name=Sonar way" -X POST http://localhost:9000/api/profiles/set_as_default

Parameters

Parameter

Description

Required

Default ValueExample Value

language

Profile language

Yes

Nonejava
nameProfile nameYesNoneSonar way