1

I am trying to upload one file to BitBucket repository (Git system). I am trying to send that using the REST API but the error Indicates that POST method is not allowed, although I can of course using the "git push" command to send new files. But if I try to POST the file I am getting this error: "HTTP Status 405 – Method Not AllowedType Status ReportMessage Request method POST not supported"

I am trying to that with this code:

$API_KEY="NDU2"
$uri="https://bitbucket.dev/projects/TEST/repos/faselect/browse/test"
$jsonFile=Get-Content -Raw -Pat C:\Users\john\Downloads\test1.json
Invoke-RestMethod -Uri $uri  -Headers @{Authorization="$("Basic {0}" -f $API_KEY)"} -Method Post -Body $jsonFile -ContentType 'application/json'
vel
  • 1,000
  • 1
  • 13
  • 35

1 Answers1

0

My approach to this would be to look on PowerShell gallery Powerhell Gallery and see if you can find what you are looking for as a start.. there are several projects that are using this rest api that you could use as an example. here is one that I found on one of those projects: Ps-bitbucket in Github

Thom Schumacher
  • 1,469
  • 13
  • 24
  • Hi @thom schumacher – vel Aug 05 '20 at 07:12
  • Hi @thom schumacher. Thanks for given example: It seems very similar to me their example.They put: `Invoke-WebRequest -Uri "$ResourceUrl" -Method $Method -Headers $Headers -UseBasicParsing -ContentType $ContentType -Body $Body` and that what I try (I was just missing this UseBasicParsing but I added that, and I am using Invoke-RestMethod instead of Invoke-WebRequest but it should be the same, but same error.. Can you help me? `Invoke-RestMethod -Uri $uri -Headers @{Authorization="$("Basic {0}" -f $API_KEY)"} -UseBasicParsing -Method Post -Body $jsonFile -ContentType 'application/json'` – vel Aug 05 '20 at 08:07