Search code examples
azure-devopsazure-devops-rest-api

Creating a pull request with autocomplete enabled Azure DevOps rest API


I'm struggling to figure out how to create a pull request with autocomplete enabled with using the API if someone can provide an example of the JSON posted to enable the autocomplete that would be awesome.

I've tried setting the autoCompleteSetBy Property and also have tried a whole bunch of settings within completionOptions Property as well.


Solution

  • You can't create a Pull Request with autocomplete enabled when you use the Create PR rest API. you can only update a current PR with autocomplete enabled with the Pull Requests - Update, so you need to create the PR, take the new ID and then update it.

    The basic body is to specify the autoCompleteSetBy with the ID of the user who actually runs the API:

    "autoCompleteSetBy":  {
                              "id":  "dsafasf-41531tf-safsaf-24124fas-sfasfasf"
                          }
    

    You can also add additional parameters with completionOptions like squash merge and more, see here.

    If you want to automate of creating Pull Requests process you can install the Create Pull Request extension.