Attach File or URL to Row - Request Body for cURL or Python
Hi all,
I'm struggling to work out how to attach a URL to a row. In the API doc I can see the request URL, but I can't find an example of the request body. I'd prefer to use cURL, alternatively python.
I would expect something like this
URL: https://api.smartsheet.com/2.0/sheets/{sheetId}/rows/{rowId}/attachments
-H "Authorization: Bearer XXXXXXXX" \ -H "Content-Type: application/json" \
Body: {rowid: "attachmenttype": LINK, "name": 'url name', "url": 'url'}
Any help is appreciated.
Thanks
Answers
-
From the docs -
curl https://api.smartsheet.com/2.0/sheets/{sheetId}/rows/{rowId}/attachments \ -H "Authorization: Bearer JKlMNOpQ12RStUVwxYZAbcde3F5g6hijklM789" \ -H "Content-Type: application/msword" \ -H 'Content-Disposition: attachment; filename="ProgressReport.docx"' \ -H "Content-Length: FILE_SIZE" \ -X POST \ --data-binary @ProgressReport.docx
Ryan
-
thanks for the reply. I have seen the docs, however this example describes how to attach a file, however I want to attach a link.
It's not clear from the docs how I adjust the curl to attach a url instead.
-
Not sure if I understand what you mean by a link as an attachment but you could add it as a discussion perhaps?
Something like this -
response = smartsheet_client.Discussions.create_discussion_on_row( 9283173393803140, # sheet_id 0123456789012345, # row_id smartsheet.models.Discussion({ 'comment': smartsheet.models.Comment({ 'text': '<your link>' }) }) )
Ryan
-
I really appreciate your help. Unfortunately discussions is not what we are after.
There is an option to attach a 'URL' to a sheet (see images below). In our case we want to attach the URL to a specific destination (different for each row).
So I guess the request body will be similar as the one you posted, but I'm haven't got enough API smarts to work out the request body for a URL attachment and per API docs it should be possible.
-
I see. I haven't done that before but here is in general how you could attach a file to a row.
updated_attachment = smartsheet_client.Attachments.attach_file_to_row( 9283173393803140, # sheet_id 0123456789012345, # row_id ('ProgressReport.docx', open('/path/to/ProgressReport.docx', 'rb'), 'application/msword') )
My guess is it would be close to this but replacing everything starting from the "open" with your URL related information. May have to try it a few times. I see the respective type of URL supported -
Attach File or URL to Row
Attaches a file to the row. The URL can be any of the following:
- Normal URL (attachmentType "LINK")
- Box.com URL (attachmentType "BOX_COM")
- Dropbox URL (attachmentType "DROPBOX")
- Egnyte URL (attachmentType "EGNYTE")
- Evernote URL (attachmentType "EVERNOTE")
- Google Drive URL (attachmentType "GOOGLE_DRIVE")
- OneDrive URL (attachmentType "ONEDRIVE")
Ryan
-
@Thomas Taresch @Ryan Kramer Am also looking for the same one like to attach URL instead of file. I got only file attachment as per API documentation. Have you got any solution on the same.
Last 2 days was searching and I came across this discussion too. Have tried the below one and its working for me, so thought to share here.
# Define the URL and attachment type
url = "https://toppng.com/uploads/preview/happy-new-year-2024-wishes-card-11692986041byplnabczr.webp"
attachment_type = "LINK" # You can change this to any supported type as per their documentation
# Create an Attachment object
attachment = smartsheet.models.Attachment({
'attachmentType': attachment_type,
'url': url
})
# Attach the URL to the row
attachment_result = smartsheet_client.Attachments.attach_url_to_row(
sheet_id,
row.id,
attachment
)
Categories
- All Categories
- 14 Welcome to the Community
- Smartsheet Customer Resources
- 64.2K Get Help
- 419 Global Discussions
- 221 Industry Talk
- 461 Announcements
- 4.8K Ideas & Feature Requests
- 143 Brandfolder
- 142 Just for fun
- 58 Community Job Board
- 462 Show & Tell
- 32 Member Spotlight
- 1 SmartStories
- 299 Events
- 38 Webinars
- 7.3K Forum Archives