Using curl for gitlab api

decided to get acquainted with gitlab api. There is a documentation https://docs.gitlab.com/ee/api/commits.html#create-a-commit-with-multiple-files-and-actions
there is an example for curl:
PAYLOAD=$(cat << ‘JSON’
{
“branch”: “master”,
“commit_message”: “some commit message”,
“actions”: [
{
“action”: “create”,
“file_path”: “foo/bar”,
“content”: “some content”
},
{
“action”: “delete”,
“file_path”: “foo/bar2”
},
{
“action”: “move”,
“file_path”: “foo/bar3”,
“previous_path”: “foo/bar4”,
“content”: “some content”
},
{
“action”: “update”,
“file_path”: “foo/bar5”,
“content”: “new content”
},
{
“action”: “chmod”,
“file_path”: “foo/bar5”,
“execute_filemode”: true
}
]
}
JSON
)
curl --request POST --header “PRIVATE-TOKEN: <your_access_token>” --header “Content-Type: application/json” --data “$PAYLOAD” https://gitlab.example.com/api/v4/projects/1/repository/commits
I try to execute through curl for my project:
curl --request POST --header "PRIVATE-TOKEN: ***" --header "Content-Type: application/json" --data '{"branch":"my_branch","commit_message":"message","actions":[{"action":"delete","file_path":"README.md"}]}' https://gitlab.com/api/v4/projects/1/repository/commits
The answer is:
HTTP / 1.1 400 Bad request
connection # 0 to host gitlab.com left intact
README.md file is not deleted, I checked PRIVATE-TOKEN - it is specified correctly, the my_branch branch exists, project ID is correct, why the file is not deleted???

hi @gitlab10

The request Type used in above API is post.
I would like to suggest you please use “DELETE” request type instead of “POST” request type for above API.