Using the Invoke-RestMethod I can successfully download files from BitBucket (GIT):
$API_KEY="ZTEyNDU2"
$uri="https://bitbucket.dev/projects/TEST/repos/select/browse/test_scripts/test1.json?raw"
Invoke-RestMethod -Headers @{Authorization="$("Basic {0}" -f $API_KEY)"} -Uri $uri -OutFile "test1.json"
Can you please advise me what will be the scenario and Invoke-RestMethod if I want to upload local test2.json file to the location in the same directory …/repos/select/browse/test_scripts/ (preferably on master branch on Git)? I am not sure also if I need to create also in the same time new subfolder on Bitbucket repository how I can do it?
Please tell me how the Invoke-RestMethod should look like? I know I need to use the -Method Post but do not know how to reference my local file that needs to be uploaded???
I tried something like this, to put local file into some repos path (but it doesn’t work):
$API_KEY=“ZTEyNDU2”
$uri=“https://bitbucket.dev/projects/TEST/repos/select/browse/test_scripts/
$jsonFile=Get-Content -Raw -Pat C:\Users\Downloads\test2.json
Invoke-RestMethod -Uri $uri -Headers @{Authorization=”$(“Basic {0}” -f $API_KEY)"} -Method ‘POST’ -Body $jsonFile -ContentType ‘application/json’
Thank you in advance!!!