Chris replied to the topic Download an Raw file from BITBUCKET Project… in
PowerShell Forum 4 years, 1 month ago
In essence what I’m saying is the problem isn’t so much with your powershell code as with your actual request to BitBucket. It thinks you’re a web browser, there’s probably some parameter they’ll accept (either in the headers, as a URI parameter after the ? or using a particular URI path) to tell them you just want to download the file, not view it.
You could also try changing from this to that
https://api.bitbucket.org/1.0/repositories/company/project/raw/HEAD/some/special/file.txt
ftp://api.bitbucket.org/1.0/repositories/company/project/raw/HEAD/some/special/file.txtChris replied to the topic Download an Raw file from BITBUCKET Project… in
PowerShell Forum 4 years, 1 month ago
There are a few things that could be going on, you’ll need to do a bit more digging to figure it out. I’ll start by suggesting a tool (Postman) and giving a bit of context into what’s probably going on.
This is what an http conversation actually looks like. Red is what we send, blue is what we get back.
https://ibb.co/bEfn9oHere’s a practical example in postman (calling out to google.com)
https://ibb.co/isjavTNotice there’s 2 places we can send parameters, in the URI and in the Headers. One of the standard headers is Content-Type which indicates the format the web server is trying to send back to you.
Try installing Postman, putting in your URI and playing around values you send in the URI and Headers, there’s probably a way to ask for it to send a text/plain instead of text/html file. Once you know what the URI and Headers need to be you should be able to translate your request into powershell code using the -URI and -Headers parameters
Chris joined the group
PowerShell 4 years, 1 month ago
Chris posted an update 4 years, 1 month ago
@mgarg007
Trying to reply about using powershell’s invoke-webrequest and getting an unexpected file type, but having some delays getting added to the group and wanted to give you a timely response.There are a few things that could be going on, you’ll need to do a bit more digging to figure it out. I’ll start by suggesting a tool (Postman) and giving a bit of context into what’s probably going on.
This is what an http conversation actually looks like. Red is what we send, blue is what we get back.
https://ibb.co/bEfn9oHere’s a practical example in postman (calling out to google.com)
https://ibb.co/isjavTNotice there’s 2 places we can send parameters, in the URI and in the Headers. One of the standard headers is Content-Type which indicates the format the web server is trying to send back to you.
Try installing Postman, putting in your URI and playing around values you send in the URI and Headers, there’s probably a way to ask for it to send a text/plain instead of text/html file. Once you know what the URI and Headers need to be you should be able to translate your request into powershell code using the -URI and -Headers parameters
Chris became a registered member 4 years, 1 month ago