This section of the Smartsheet API Documentation should help with the syntax:
https://smartsheet.redoc.ly/tag/attachments/#operation/row-attachments-attachFile
Apologies if you've already found this resource.
How can I use API to attach a local PDF to a Smartsheet row through Kofax/Tungsten?
Best Answer
-
Alright, I figured it out.
Here's the answer for attaching a local PDF file in case anyone else needs it in the future.
In Kofax/Tungsten Design Studio:
- Create a Simple PDF variable.
- Load your PDF to this variable using the Load File action.
- Create a variable to store your PDF's name.
- Convert that variable using Evaluate Expression "Content-Disposition:attachment; filename='"+PDF_Name_Variable +"'"
- Do a text replace on this variable to replace ' with "
- Create a Call REST Web Service action.
- Configure this action with the URL "https://api.smartsheet.com/2.0/sheets/YOUR_SHEET_ID/rows/YOUR_ROW_ID/attachments"
- Set the Request Type to POST
- Specify raw body.
- Set the raw body to your Simple PDF variable.
- Set the content type to application/json.
- Set the Output to Load in Browser.
- Scroll down to the "Additional Headers to Send" section.
- Add a custom header "Authorization: Bearer YOUR_BEARER_TOKEN"
- Add a Content-Type header "Content-Type:application/pdf"
- Add the variable you made earlier for "Content-Disposition:attachment; filename='"+PDF_Name_Variable +"'"
- You may need to complete the Credantials section. Just include your Username and Password.
That's it. You do not need to build a Content-Length header.
It will end up sending something like this:
cURL https://api.smartsheet.com/2.0/sheets/{SHEET_ID}/rows/{ROW_ID}/attachments
-H "Authorization: Bearer YOUR_BEARER_TOKEN"
-H "Content-Type: application/pdf"
-H 'Content-Disposition: attachment; filename="YOUR_FILE_NAME"'
--data-binary @YOUR_FILE_CONTENT.pdf
Answers
-
This section of the Smartsheet API Documentation should help with the syntax:
Apologies if you've already found this resource.
Jessica Selano | Selano Consulting
jessica@selanoconsulting.com
-
Hi Jessica,
Yes, I've been attempting to make sense of the documentation as it relates to attaching a PDF.
The example given in the documentation is for a .docx file.
Also, I'm unsure how to provide the local directory path in the API. -
Here is an example of json syntax that works in Bridge. This attaches a PDF that is in SharePoint to a row.
Endpoint:
https://api.smartsheet.com/2.0/sheets/{sheetId}/rows/{rowId}/attachments
Method: POST
Request Body:
{
"attachmentType": "ONEDRIVE",
"name": "ATTACHMENT",
"url": "https://cambrex.sharepoint.com/:b:/r/sites/Smartsheet/Smartsheet%20Training/Smartsheet%20Instructions%20for%20Clients.pdf?csf=1&web=1&e=KyWdQP"
}Jessica Selano | Selano Consulting
jessica@selanoconsulting.com
-
Alright, I figured it out.
Here's the answer for attaching a local PDF file in case anyone else needs it in the future.
In Kofax/Tungsten Design Studio:
- Create a Simple PDF variable.
- Load your PDF to this variable using the Load File action.
- Create a variable to store your PDF's name.
- Convert that variable using Evaluate Expression "Content-Disposition:attachment; filename='"+PDF_Name_Variable +"'"
- Do a text replace on this variable to replace ' with "
- Create a Call REST Web Service action.
- Configure this action with the URL "https://api.smartsheet.com/2.0/sheets/YOUR_SHEET_ID/rows/YOUR_ROW_ID/attachments"
- Set the Request Type to POST
- Specify raw body.
- Set the raw body to your Simple PDF variable.
- Set the content type to application/json.
- Set the Output to Load in Browser.
- Scroll down to the "Additional Headers to Send" section.
- Add a custom header "Authorization: Bearer YOUR_BEARER_TOKEN"
- Add a Content-Type header "Content-Type:application/pdf"
- Add the variable you made earlier for "Content-Disposition:attachment; filename='"+PDF_Name_Variable +"'"
- You may need to complete the Credantials section. Just include your Username and Password.
That's it. You do not need to build a Content-Length header.
It will end up sending something like this:
cURL https://api.smartsheet.com/2.0/sheets/{SHEET_ID}/rows/{ROW_ID}/attachments
-H "Authorization: Bearer YOUR_BEARER_TOKEN"
-H "Content-Type: application/pdf"
-H 'Content-Disposition: attachment; filename="YOUR_FILE_NAME"'
--data-binary @YOUR_FILE_CONTENT.pdf
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 66.4K Get Help
- 430 Global Discussions
- 152 Industry Talk
- 492 Announcements
- 5.2K Ideas & Feature Requests
- 85 Brandfolder
- 155 Just for fun
- 76 Community Job Board
- 504 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 307 Events
- 37 Webinars
- 7.3K Forum Archives