4

we try to automate the creation of projects (including user/group Management) in sonarqube and I already found the Web-API-documentation in our sonarqube 5.6-Installation. But if I try to create a project with the following settings

JSON-File create-project.json:

{"key": "test1", "name": "Testprojekt1"}

curl-request

curl --noproxy '*' -D -X POST -k -u admin:admin -H 'content-type: application/json' -d create_project.json http://localhost:9000/api/projects/create

I get the Error:

{"err_code":400,"err_msg":"Missing parameter: key"}

It's a bit strange because if I try e.g. the URL:

http://localhost:9000/api/projects/index

I get the list of the projects I created manuelly and if I try a request like

curl -u admin:admin -X POST 'http://localhost:9000/api/projects/create?key=myKey&name=myProject' 

it works too, but I would like to use the new api because it looks like it support much more function that the 4.X API of sonarqube. Maybe someone here can help me with this problem, if would very thanksful for every useful hint. best regards Dan

G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
  • What new API are you talking about? If you look at https://sonarqube.com/web_api/api/projects, you'll see that there's only 1 API to create projects, and it was introduced in SQ 4.0 – Fabrice - SonarSource Team Jun 24 '16 at 09:08
  • Exactly the API you linkend in your comment, maybe I just need an example how I can create a project/group/ with this api. Because I don't get it how I transfer the knowledge from the documentation to a working example... –  Jun 24 '16 at 10:21
  • 2
    The way to do it is exactly the last command that you specified in your question, not more, not less. – Fabrice - SonarSource Team Jun 24 '16 at 11:19

1 Answers1

5

I found this question because I got the same "parameter missing" error message.

So what we both did not understand: The SQ API expects the parameters as plain URL parameters and not as json formatted parameters as most REST APIs do today.

PS: Would be nice if this could be added to the SQ documentation.

Horst Krause
  • 636
  • 7
  • 22