Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Why I can't download excel file in PullRequest with rest API?

cngufeng1
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 15, 2025

1. In PullRequest Review, if excel, bitbucket guide me that excel file can't view diff online and guide me to download old & new file mannually.
2, I choose to download new file, when click 'new file' button, excel will save to my download folder of my PC. excel file content seems Ok.

3. Now I want to download the "new file' with python script, with AI support I earned following codes:
~~~~~~~~~~~~~~~~~~~

import requests
bitbucket_token = "xxxxxx"
headers = {
"Authorization": f"Bearer {bitbucket_token}"
}
download_url = "https://aadev-aa.aaa.com/git/projects/aa/repos/bb/raw/Release/aaa.xlsx?at=xxxxxxxxxx"
file_response = requests.get(download_url, headers=headers)
tmp_file = "d:\\temp_download11111.xlsx"
with open(tmp_file, 'wb') as f:
f.write(file_response.content)
~~~~~~~~~~~~~~~~~~

temp_download11111.xlsx can be download, but it's a ascii file rather than an excel file and If I rename suffix from xlsx to html, it's looks like following: (BTW, about the token, for other purposes, following are all works:

    headers = {
        "Authorization": f"Bearer {bitbucket_token}",
        "Content-Type": "application/json"
    }

111.png

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events