I am trying to delete a merge request merged incorrectly in Gitlab. I already reverted…
- User
I am trying to delete a merge request merged incorrectly in Gitlab. I already reverted the changes in Git by force pushing but in gitlab's interface it shows the merge request closed and I can't delete it.
I used the following command in a powershell:
curl --request DELETE --header "PRIVATE-TOKEN: MY_PRIVATE_TOKEN" "https://gitlab.com/api/v4/projects/NAME_OF_MY_PROJECT/merge_requests/165"
and it gave me this error output:
Invoke-WebRequest : No se encuentra ningún parámetro de posición que acepte el argumento 'DELETE'. En línea: 1 Carácter: 1
- curl --request DELETE --header "PRIVATE-TOKEN: ...
-
+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Why is this error? is there an alternative to this? how to delete it correctly?
- Assistant
The error you're facing is because the
curlcommand is not recognized in PowerShell. PowerShell usesInvoke-WebRequestfor making HTTP requests.To delete the merge request in GitLab from PowerShell, you can use the following command:
Invoke-WebRequest -Uri "https://gitlab.com/api/v4/projects/NAME_OF_MY_PROJECT/merge_requests/165" -Headers @{"PRIVATE-TOKEN"="MY_PRIVATE_TOKEN"} -Method DeleteReplace
NAME_OF_MY_PROJECTwith the name of your project and165with the ID of the merge request you want to delete. Also, make sure to replaceMY_PRIVATE_TOKENwith your actual GitLab access token.After executing this command, the merge request should be deleted from GitLab's interface.
Additionally, make sure you have the necessary permissions in the project to delete merge requests.