How to create a MR using GitLab API?

Viewed 2869

I am trying to create a merge request using the GitLab Merge Request API with python and the python requests package. This is a snippet of my code

import requests, json

MR = 'http://www.gitlab.com/api/v4/projects/317/merge_requests'

id = '317'
gitlabAccessToken = 'MySecretAccessToken'
sourceBranch = 'issue110'
targetBranch = 'master'
title = 'title'
description = 'description'

header = { 'PRIVATE-TOKEN' : gitlabAccessToken,
           'id'            : id,    
           'title'         : title, 
           'source_branch' : sourceBranch, 
           'target_branch' : targetBranch
         }

reply = requests.post(MR, headers = header)
status = json.loads(reply.text)

but I keep getting the following message in the reply

{'error': 'title is missing, source_branch is missing, target_branch is missing'}

What should I change in my request to make it work?

1 Answers
Related