I have been trying to download a file(to get the file content) which is in file attachment list of a ticket. Below is my python code, please have a look:
import requests, os
def download_file_attachment(space, document_id):
try:
ASSEMBLA_BASE_URL = 'https://api.assembla.com/v1/'
space_id = "my-space-id"
url = os.path.join(ASSEMBLA_BASE_URL, "spaces", space_id, "documents", str(document_id), "download")
print url
response = get_assembla(url)
return response
except:
return None
def get_assembla(url, params={}, headers={}):
headers = { 'X-Api-Key': ASSEMBLA_API_KEY,
'X-Api-Secret' : ASSEMBLA_API_KEY_SECRET,
'Content-type' : 'application/json' }
retry_count = 0
response = None
while retry_count < 5:
try:
response = requests.get(url, params=params, headers=headers, verify=False, allow_redirects=True)
break
except:
retry_count += 1
return response
# Calling below
response = download_file_attachment(space, attribute_document_id)
When im running the above code, im getting 403 response.
This is what I recived in logs:
"GET /a881ee/bjtzxqedyr47RdacwqjQWU/bcCjksTLCr5Odcdmr6QqzO_1?response-content-disposition=inline%3B%20filename%3D%22my_dict.txt%22%3B%20filename%2A%3DUTF-8%27%27my_dict.txt&Signature=iePt2HSUfrwBnFomYHgQ8gfaGYw%3D&Expires=1480443290&AWSAccessKeyId=0VPMNHAQ0JNX91QHHP02 HTTP/1.1" 403 None
I have also seen this reference link but it didnt help much:
http://api-doc.assembla.com/content/ref/documents_download.htmlCan anyone please help me that what I am doing wrong?