[英]Pull request using Stash rest api
I am trying to create pull request using rest API.我正在尝试使用 rest API 创建拉取请求。 I went through the documentaion .
我浏览了文档。 I am doing a post request as mentioned in the doc with below json
我正在使用以下 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"
}
}
]
}
but I am getting an error in response但我收到一个错误响应
{
"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
}
]
}
I dont know what permission parameter to add in json request.我不知道要在 json 请求中添加什么权限参数。 Please help me with this.
请帮我解决这个问题。 This is save a lot of time for me.
这对我来说节省了很多时间。
I refined my json a bit seeing this post and worked for me, here is my request if someone still looking for workaround,我看到这篇文章对我的json进行了一些改进并为我工作,如果有人仍在寻找解决方法,这是我的要求,
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 }' 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 }'
Note - Replace bitbucketURL, userName, passWord, projectName, repoName, sourceBranch, destinationBranch, userId with your details.注意- 用您的详细信息替换 bitbucketURL、userName、passWord、projectName、repoName、sourceBranch、destinationBranch、userId。
The POST needs an authentication method. POST 需要一种身份验证方法。 See https://developer.atlassian.com/static/rest/stash/3.11.6/stash-rest.html#authentication .
请参阅https://developer.atlassian.com/static/rest/stash/3.11.6/stash-rest.html#authentication 。
Pull Requests covers a bit more about the permissions needed for the repos involved. 拉取请求更多地介绍了所涉及的存储库所需的权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.