Reputation: 631
I'm trying to create a XPath custom rule with the Sonar API, but I have an issue when adding the parameters.
Here is my HTTP request :
http.sendPostRequest("http://localhost:9000/api/rules/create"
+ "?custom_key=test"
+ "&markdown_description=test"
+ "&name=test"
+ "¶ms=expression=test;filePattern=test;message=test"
+ "&severity=BLOCKER"
+ "&template_key=xml:XPathCheck");
I receive a code 200 and the rule is created in Sonar, except the parameters "params" are empty.
I've checked the API's documentation, it says it should be something like "params=key1=v1;key2=v2", it meets this format but still doesn't work.
Upvotes: 1
Views: 309
Reputation: 2587
It's not possible to use a key that was already used by another key, even when this rule is removed. You need to add the parameter prevent_reactivation=true in order to fail if a rule already exists with this key.
Upvotes: 1
Reputation: 631
So, I find out that if you create a new rule with the same key than a previously deleted rule, it recovers its parameters.
For my case, I've tried to create a rule with the key "test", but before this, I create and delete a rule "test" with no parameters. It seems that Sonar have some sort of cache.
Upvotes: 1