Set webhook for project through REST api

Version 6.7.5 (build 38563)

I have some script code that dynamically creates a SonarQube project with a certain configuration, based on the configuration of an existing project. Up to now, only the quality gate and quality profile were copied over. I now realize that I have to copy the webhook value also.

So, on the page where I set the webhook, I see that it says this is property “sonar.webhooks.project”.

I first got the output from “/api/properties/”. This worked, returning a long list of key/value pairs of existing SonarQube properties. I assume this is a “global” list, not for specific projects.

I then tried getting “/api/properties/sonar.webhooks.project?resource=…”. The best response I could get from this was “[]” (empty list). I do have the webhook value set in the project id I specified, and it’s been saved there for a while.

I don’t see any way to get all the properties specific to a resource. I tried several logical variations of the “properties” service, and they all ignored the “resource” parameter and just gave me (apparently) all of the global properties.

I hope this isn’t another “can’t do that in your version” issue.


While in v7.1+, webhooks can be created for a specific project with the POST api/webhooks/create API, in v6.7.5 you can use the POST api/settings/set API to manage the sonar.webhooks.project setting on your projects.

The properties web service was deprecated in 6.3, and the settings web service should now be used for managing settings. That should be noted in the Web API documentation of your instance.


1 Like

Sigh. I keep on forgetting about the webapi link. Using the doc for the wrong version will never work. I get into this once every few months and seem to forget about the webapi link each time. I think I’ve made sure I won’t forget it this time. I’ve verified I can get the property value, and I’m confident the setting part will work (I have other code that does something similar).

1 Like