TL;DR : Where can I find the documentation on what to pass to the POST request in order to create a Pull Request ? (What to put in the JSON)
----------
Using a Groovy script, I'm trying to automatize some tasks that include a commit/push of a tmp branch on multiple projects. I want to automatically create pull request between the tmp branch and the prod branch of all those projects at the end of my script. In order to do so, I tried using the BitBucket REST API.
I found this documentation which gave me the following endpoint to use with a POST request : /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests.
This endpoint need the following JSON :
<span>{</span>
<span>"title"</span><span>:</span> <span>"Talking Nerdy"</span><span>,</span>
<span>"description"</span><span>:</span> <span>"It’s a kludge, but put the tuple from the database in the cache."</span><span>,</span>
<span>"state"</span><span>:</span> <span>"OPEN"</span><span>,</span>
<span>"open"</span><span>:</span> <span>true</span><span>,</span>
<span>"closed"</span><span>:</span> <span>false</span><span>,</span>
<span>"fromRef"</span><span>:</span> <span>{</span>
<span>"id"</span><span>:</span> <span>"refs/heads/feature-ABC-123"</span><span>,</span>
<span>"repository"</span><span>:</span> <span>{</span>
<span>"slug"</span><span>:</span> <span>"my-repo"</span><span>,</span>
<span>"name"</span><span>:</span> <span>null</span><span>,</span>
<span>"project"</span><span>:</span> <span>{</span>
<span>"key"</span><span>:</span> <span>"PRJ"</span>
<span>}</span>
<span>}</span>
<span>},</span>
<span>"toRef"</span><span>:</span> <span>{</span>
<span>"id"</span><span>:</span> <span>"refs/heads/master"</span><span>,</span>
<span>"repository"</span><span>:</span> <span>{</span>
<span>"slug"</span><span>:</span> <span>"my-repo"</span><span>,</span>
<span>"name"</span><span>:</span> <span>null</span><span>,</span>
<span>"project"</span><span>:</span> <span>{</span>
<span>"key"</span><span>:</span> <span>"PRJ"</span>
<span>}</span>
<span>}</span>
<span>},</span>
<span>"locked"</span><span>:</span> <span>false</span><span>,</span>
<span>"reviewers"</span><span>:</span> <span>[</span>
<span>{</span>
<span>"user"</span><span>:</span> <span>{</span>
<span>"name"</span><span>:</span> <span>"charlie"</span>
<span>}</span>
<span>}</span>
<span>]</span>
<span>}</span>However, I can't find any information on how to build this JSON ...
I can guess what title and description are, but what are state, open, closed, etc. for ? How do I build a correct fromRef.id ? Why the repo name is set to null ? which attribute are optional ? How does reviewers[i].user works ? If I only put my BitBucket login in reviewers[i].user.name will it work ? etc.
Every answers I've found on this subject is just a copy/past this same JSON, and everybody seems to understand how it works without any explanations... Did I miss something ?
Anyway, here is my real question : where can I find some documentation on this Pull Request JSON Object ?
Thanks.
Additional information :
- BitBucket Server V5.7.1
- I am not administrator of my BitBucket platform.
- I am administrator (+ Read/Write) of my BitBucket Project (and all repo inside it)