debian-mirror-gitlab/doc/api/suggestions.md

45 lines
1.3 KiB
Markdown
Raw Normal View History

2020-10-24 23:57:45 +05:30
---
stage: Create
group: Source Code
2021-02-22 17:27:13 +05:30
info: "To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments"
2020-10-24 23:57:45 +05:30
type: reference, api
---
2021-03-11 19:13:27 +05:30
# Suggest Changes API **(FREE)**
2019-02-15 15:39:39 +05:30
2021-09-04 01:27:46 +05:30
This page describes the API for [suggesting changes](../user/project/merge_requests/reviews/suggestions.md).
2019-02-15 15:39:39 +05:30
Every API call to suggestions must be authenticated.
## Applying suggestions
2022-04-04 11:22:00 +05:30
Applies a suggested patch in a merge request. Users must have
at least the Developer role to perform such action.
2019-02-15 15:39:39 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2019-02-15 15:39:39 +05:30
PUT /suggestions/:id/apply
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer/string | yes | The ID of a suggestion |
2021-03-11 19:13:27 +05:30
| `commit_message` | string | no | A custom commit message to use instead of the default generated message or the project's default message |
2019-02-15 15:39:39 +05:30
2020-03-13 15:44:24 +05:30
```shell
2020-06-23 00:09:42 +05:30
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/suggestions/5/apply"
2019-02-15 15:39:39 +05:30
```
Example response:
```json
{
"id": 36,
"from_line": 10,
"to_line": 10,
2022-07-23 23:45:48 +05:30
"applicable": false,
2019-02-15 15:39:39 +05:30
"applied": true,
"from_content": " \"--talk-name=org.freedesktop.\",\n",
"to_content": " \"--talk-name=org.free.\",\n \"--talk-name=org.desktop.\",\n"
}
```