Ali*_*Ali 5 python http-post python-requests gitlab gitlab-api
我正在尝试使用GitLab合并请求API和python和python请求包创建合并请求。这是我的代码的一部分
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)
Run Code Online (Sandbox Code Playgroud)
但我在回复中不断收到以下消息
{'error': 'title is missing, source_branch is missing, target_branch is missing'}
Run Code Online (Sandbox Code Playgroud)
我应该更改其要求以使其正常工作吗?
除之外PRIVATE-TOKEN,所有参数都应作为形式编码的参数传递,这意味着:
header = {'PRIVATE-TOKEN' : gitlabAccessToken}
params = {
'id' : id,
'title' : title,
'source_branch' : sourceBranch,
'target_branch' : targetBranch
}
reply = requests.post(MR, data=params, headers=header)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
738 次 |
| 最近记录: |