Hello Smartsheet Community!
I need help downloading attachments from a sheet that currently has a little over five thousand lines and manually downloading isn't ideal.
I was able to extract the metadata for my sheet and revising the documentation for the Attachment Object I was able to extract the attachment id and other attributes but was missing the entire block which contained the url attribute.
I'm using python SDK with the code below
sheet = smartsheet_client.Sheets.get_sheet(sheet_id, include='attachments')
Alternatively I have also used
url = f"https://api.smartsheet.com/2.0/sheets/{sheet_id}?include=attachments"
headers = {
"Authorization": f"Bearer API CODE",
"Accept": "application/json"
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
sheet_metadata = response.json()
print(json.dumps(sheet_metadata, indent=4)) # Pretty-print the JSON response
else:
print(f"Error: {response.status_code}, {response.json()}")
This is what my metadata is returning (example):
{
"id": 0,
"parentId": 0,
"attachmentType": "BOX_COM",
"attachmentSubType": "DOCUMENT",
"mimeType": "PNG",
"parentType": "COMMENT",
"createdAt": "2019-08-24T14:15:22Z",
"createdBy": {
"email": "jane.doe@smartsheet.com",
"name": "Jane Doe"
}
This is what should be returning:
{
"id": 0,
"parentId": 0,
"attachmentType": "BOX_COM",
"attachmentSubType": "DOCUMENT",
"mimeType": "PNG",
"parentType": "COMMENT",
"createdAt": "2019-08-24T14:15:22Z",
"createdBy": {
"email": "jane.doe@smartsheet.com",
"name": "Jane Doe"
},
"name": "string",
"sizeInKb": 0,
"url": "string",
"urlExpiresInMillis": 0
}
Without the url attribute I'm unable to use the get_attachment method.
Any idea what I'm doing wrong? Any help is truly appreciated.