问题描述
我正在尝试使用rest API创建请求请求.我经历了文档.我正在执行文档中提到的json以下
I am trying to create pull request using rest API. I went through the documentaion . I am doing a post request as mentioned in the doc with below json
{
"title": "blah blah",
"description": "blah blah",
"state": "OPEN", "open": true,
"closed": false,
"fromRef":
{
"id": "feature/test1",
"repository":
{
"slug": "test-repo",
"name": null,
"project":
{
"key": "PR"
}
}
},
"toRef":
{
"id": "refs/heads/master",
"repository":
{
"slug": "test-repo",
"name": null,
"project":
{
"key": "PR"
}
}
},
"locked": false,
"reviewers": [
{
"user":
{
"name": "nikhil"
}
}
]
}
但我在响应中遇到错误
{
"errors":
[
{
"context":"type","message":"Please enter a type of permission","exceptionName":null
},
{
"context":"permitted","message":"Please enter at least one user or group","exceptionName":null
}
]
}
我不知道要在json请求中添加什么权限参数.请帮我解决一下这个.这为我节省了很多时间.
I dont know what permission parameter to add in json request. Please help me with this. This is save a lot of time for me.
推荐答案
我对json有所了解,并为我工作了一些,这是我的请求,如果有人仍在寻找解决方法,这是我的要求,
I refined my json a bit seeing this post and worked for me, here is my request if someone still looking for workaround,
卷曲-X POST -H内容类型:application/json" -u userName:passWord --basic https://bitbucketURL/rest/api/1.0/projects/projectName/repos/repoName/pull-requests -d'{标题": 放一些标题",描述":放一些描述", "fromRef":{"id":"sourceBranch",存储库":{"slug":"repoName","name":null,"project":{"key":"projectName}}}," toRef:{" id:" destinationBranch,"存储库:{" slug:" repoName," name:null," project:{" key:" projectName} }},评论者":[{"user":{"name":"userId"}}}],"close_source_branch":false}'
curl -X POST -H "Content-Type: application/json" -u userName:passWord --basic https://bitbucketURL/rest/api/1.0/projects/projectName/repos/repoName/pull-requests -d '{ "title": "put some title", "description": "put some desc", "fromRef": { "id": "sourceBranch", "repository": { "slug": "repoName", "name": null, "project": { "key": "projectName" }}}, "toRef": {"id": "destinationBranch","repository":{"slug": "repoName", "name": null, "project": {"key": "projectName"}}}, "reviewers":[{"user":{"name": "userId"}}],"close_source_branch": false }'
注意-用您的详细信息替换bitbucketURL,userName,passWord,projectName,repoName,sourceBranch,destinationBranch,userId.
Note - Replace bitbucketURL, userName, passWord, projectName, repoName, sourceBranch, destinationBranch, userId with your details.
这篇关于使用Stash Rest API拉取请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!