Setting auto-merge using the API fails when the option is available in the UI

Summary

Setting a merge request to auto-merge using the API fails with a 405 Method Not Allowed message even tough the button is available in the UI.

Steps to reproduce

  1. Create a project and activate the Pipelines must succeed option under Project settings -> Merge requests

  2. Create a branch with the following .gitlab-ci.yml file

    Job 1:
      script: exit 1
  3. Create a MR

  4. Observe the MR has the auto-merge button available.

    Screenshot_2024-09-12_at_22.50.36

  5. Try setting the MR o auto-merge using the API. The call fails with a 405 message.

    curl --request PUT -H "PRIVATE-TOKEN:  <token>" "https://gitlab.com/api/v4/projects/:id/merge_requests/:iid/merge?merge_when_pipeline_succeeds=true"
    {"message":"405 Method Not Allowed"

Example Project

What is the current bug behavior?

What is the expected correct behavior?

Relevant logs and/or screenshots

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes