I'm working with the REST API for Gitlab, part currently we need to update one submodule using the API, in curl
the process should be something like this:
curl --request PUT -v --header "PRIVATE-TOKEN: XXXXXXXXXX" "http://mygitlab.com/api/v4/projects/1/repository/submodules/MYSUBMODULE" \
--data "branch=master&commit_sha=6bf09c4a3dc4ca79cbe301e6add06005f38ad9e3&commit_message=Update submodule reference"
And with curl
this work without any problem, but we need to do this using PowerShell, we are trying to use Invoke-RestMethod for Powershell 5.1 and according to the documentaion should be something like this:
Invoke-RestMethod -Headers @{"PRIVATE-TOKEN"="$TOKEN"} -Method Put -Uri "http://mygitlab.com/api/v4/projects/1/repository/submodules/MYSUBMODULE" -Body "branch=master&commit_sha=6bf09c4a3dc4ca79cbe301e6add06005f38ad9e3&commit_message=Update submodule reference"
but our result is the following:
Invoke-RestMethod : {"error":"commit_sha is missing, branch is missing"} At C:\version-manager\release.ps1:67 char:1 + Invoke-RestMethod -Headers @{"PRIVATE-TOKEN"="$TOKEN"} -Method Put -U ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Please notice is like doesn't get the body, and as far as I know what in curl
is --data
in PowerShell should be -Body
.
Any Idea how to fix this?
-Body @{branch = 'master';commit_sha = '6bf09c4a3dc4ca79cbe301e6add06005f38ad9e3';commit_message = 'Update submodule reference'}
– Mathias R. Jessen