Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 26 Next »

Table of Contents

This page lists all the available Web Services to be used by any HTTP clients.

Available Web Services

Violations and Reviews

Domain

Examples of use cases that can be fulfilled

Web Service
Violations
  • get a list of violations on a given resource
  • get all the violations of a project
  • get the blocker and critical violations of a project
/api/violations
Reviews
  • get a list of reviews
  • create a review
  • update a review (add comment, reassign it, etc.)
/api/reviews
Rules
  • get a list of rules
/api/rules
Quality Profiles
  • get the list of coding rules activated in a quality profile
  • backup a quality profile
  • restore a quality profile
/api/profiles

Projects and Measures

Domain

Examples of use cases that can be fulfilled

Web Service
Measures, Resources
  • get a list of resources
  • get the measures of a list of metrics on a given resource
/api/resources
Manual Measures
  • get a list of manual measures
  • create a manual measure
  • delete a manual measure
/api/manual_measures
Metrics
  • get a list of metrics
  • create a metric
  • update a metric
  • delete a metric
/api/metrics
Time Machine
  • get past measures
/api/timemachine
Sources
  • get a list of lines from source files
/api/sources
Events
  • get a list of events from a project
  • get a list of global events
  • create an event
/api/events

User

Domain

Examples of use cases that can be fulfilled

Web Service
User Properties
  • get a list of user properties
  • create a user property
  • update a user property
  • delete a user property
/api/user_properties
Favourites
  • get the logged in user's list of favourites
  • create a favourite
  • delete a favourite
/api/favourites

Administration

Domain

Examples of use cases that can be fulfilled

Web Service
Project Settings
  • delete a project
/api/projects
Properties
  • get a list of properties
  • create a property
  • update a property
  • delete a property
/api/properties
Server
  • get the status of the Sonar server
  • upgrade the Sonar database
  • get the system properties, server info (Java, OS), database configuration, JVM statistics and installed plugins
/api/server
Update Center
  • get the list of all the plugins installed on the Sonar instance
/api/updatecenter/installed_plugins

Simple MS Excel Samples

  1. Extracting a list of Measures of a Project: download the MS Excel sample

  2. Extracting all the Violations of a Project: download the MS Excel sample

Authentication

Icon

In case your Sonar server is secured, you will also have to manage authentication. Here's an MS Excel sample to deal with it.

Response Formats

The API provides several response formats such as XML, JSON (ie. JavaScript Object Notation) plain text or CSV.

Check the available formats on the page of each web service.

HTTP Status Codes

HTTP Code

Description

200

OK

400

Bad request.
The request could not be understood by the server due to malformed syntax.

401

Unauthorized

403

Forbidden.
The request was a legal request, but the server is refusing to respond to it.

404

The requested resource could not be found.

500

Internal server error.

Authentication

URL

/sessions/login

HTTP MethodGET

Security

None

Examples

Use Case

Example Request

Authenticate on http://localhost:9000 with user admin (password = admin)

GET http://localhost:9000/sessions/login?login=admin&password=admin

?Q?

Basic HTTP authentication is also supported. Example with curl to create an event

curl -u admin:admin -d "resource=org.codehaus.sonar:sonar&category=Alert&name=myAlertName&description=myAlertDescription" http://localhost:9000/api/events

Parameters

Parameter

Description

Required

Default Value

login

User login

Yes

None

password

User password

Yes

None
  • No labels