Gitlab API, Merge When Build Succeeds
<p>I'd like to set the merge_when_build_succeeds attribute of a merge request with the Gitlab API. The <a href="http://docs.gitlab.com/ce/api/merge_requests.html#accept-mr" rel="nofollow">docs</a> says, that when the optional <code>merged_when_build_succeeds</code> parameter is <code>true</code>, the MR'll be accepted only after the build succeeds.</p>

<p>How should I provide this <code>merged_when_build_succeeds</code> parameter to the API? I tried the following <code>curl</code> commands without any success:</p>

<pre><code># In the request's body
vilmosnagy@vnagy-dell:~$ curl -X PUT --header "PRIVATE-TOKEN: zvzK7CNzx9WviV5iChyg" -d merged_when_build_succeeds=true "http://localhost:8080/api/v3/projects/1/merge_requests/9/merge"
{"message":"405 Method Not Allowed"}

# In the URL
vilmosnagy@vnagy-dell:~$ curl -X PUT --header "PRIVATE-TOKEN: zvzK7CNzx9WviV5iChyg" "http://localhost:8080/api/v3/projects/1/merge_requests/9/merge?merged_when_build_succeeds=true"
{"message":"405 Method Not Allowed"}

# I tried this also, maybe the __merged__ is a mistake in the docs
vilmosnagy@vnagy-dell:~$ curl -X PUT --header "PRIVATE-TOKEN: zvzK7CNzx9WviV5iChyg" -d merge_when_build_succeeds=true "http://localhost:8080/api/v3/projects/1/merge_requests/9/merge"
{"message":"405 Method Not Allowed"}

# In the URL
vilmosnagy@vnagy-dell:~$ curl -X PUT --header "PRIVATE-TOKEN: zvzK7CNzx9WviV5iChyg" "http://localhost:8080/api/v3/projects/1/merge_requests/9/merge?merge_when_build_succeeds=true"
{"message":"405 Method Not Allowed"}

# Some other CURL parameters
vilmosnagy@vnagy-dell:~$ curl -X PUT --header "PRIVATE-TOKEN: zvzK7CNzx9WviV5iChyg" -H "Content-Type: multipart/form-data;" -F "merge_when_build_succeeds=true" "http://localhost:8080/api/v3/projects/1/merge_requests/9/merge"
{"message":"405 Method Not Allowed"}

# Some other CURL parameters
vilmosnagy@vnagy-dell:~$ curl -X PUT --header "PRIVATE-TOKEN: zvzK7CNzx9WviV5iChyg" -H "Content-Type: multipart/form-data;" -F "merged_when_build_succeeds=true" "http://localhost:8080/api/v3/projects/1/merge_requests/9/merge"
{"message":"405 Method Not Allowed"}
</code></pre>

<p>The new feature, <em>'Only allow merge requests to be merged if the build succeeds'</em> is turned on. When I turn off this feature any call of the previous calls merge the MR before the build finished, see: <a href="https://snag.gy/06nOEm.jpg" rel="nofollow">https://snag.gy/06nOEm.jpg</a></p>

<p>The private token, and the URL is right. I can query the MR's info:</p>

<pre><code>vilmosnagy@vnagy-dell:~$ curl -X GET --header "PRIVATE-TOKEN: zvzK7CNzx9WviV5iChyg" "http://localhost:8080/api/v3/projects/1/merge_requests/9"
{"id":9,"iid":9,"project_id":1,"title":"enters","description":"","state":"opened","created_at":"2016-06-29T15:36:15.235Z","updated_at":"2016-06-29T15:36:15.235Z","target_branch":"master","source_branch":"features/long_build_05","upvotes":0,"downvotes":0,"author":{"name":"Vilmos Nagy","username":"vilmos.nagy","id":2,"state":"active","avatar_url":"http://www.gravatar.com/avatar/4f94d9571ec83f42a85651291296f503?s=80\u0026d=identicon","web_url":"http://172.21.0.3/u/vilmos.nagy"},"assignee":null,"source_project_id":2,"target_project_id":1,"labels":[],"work_in_progress":false,"milestone":null,"merge_when_build_succeeds":false,"merge_status":"can_be_merged","subscribed":false,"user_notes_count":0}
</code></pre>

<p>And I can accept the MR after the build succeeds:</p>

<pre><code>vilmosnagy@vnagy-dell:~$ curl -X PUT --header "PRIVATE-TOKEN: zvzK7CNzx9WviV5iChyg" "http://localhost:8080/api/v3/projects/1/merge_requests/9/merge"
{"id":9,"iid":9,"project_id":1,"title":"enters","description":"","state":"merged","created_at":"2016-06-29T15:36:15.235Z","updated_at":"2016-06-29T16:13:41.242Z","target_branch":"master","source_branch":"features/long_build_05","upvotes":0,"downvotes":0,"author":{"name":"Vilmos Nagy","username":"vilmos.nagy","id":2,"state":"active","avatar_url":"http://www.gravatar.com/avatar/4f94d9571ec83f42a85651291296f503?s=80\u0026d=identicon","web_url":"http://172.21.0.3/u/vilmos.nagy"},"assignee":null,"source_project_id":2,"target_project_id":1,"labels":[],"work_in_progress":false,"milestone":null,"merge_when_build_succeeds":false,"merge_status":"can_be_merged","subscribed":true,"user_notes_count":0}
</code></pre>

<p>Could  you help me, and give me the correct call of the given API?</p>

<p>Thanks!</p>

<p>Vilmos</p>