API & Developers

API & Developers

Connect with other developers from around the world and collaborate on ideas using the Smartsheet API.

How can I use API to attach a local PDF to a Smartsheet row through Kofax/Tungsten?

I've been trying to figure out how to configure Kofax's Call REST Web Service step so I can use an API to attach local PDFs to specific rows of a Smartsheet.

I keep hitting dead ends or examples for everything besides PDFs.
Anyone out there know how to accomplish this task?

Best Answer

  • 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:

    1. Create a Simple PDF variable.
    2. Load your PDF to this variable using the Load File action.
    3. Create a variable to store your PDF's name.
    4. Convert that variable using Evaluate Expression "Content-Disposition:attachment; filename='"+PDF_Name_Variable +"'"
    5. Do a text replace on this variable to replace ' with "
    6. Create a Call REST Web Service action.
    7. Configure this action with the URL "https://api.smartsheet.com/2.0/sheets/YOUR_SHEET_ID/rows/YOUR_ROW_ID/attachments"
    8. Set the Request Type to POST
    9. Specify raw body.
    10. Set the raw body to your Simple PDF variable.
    11. Set the content type to application/json.
    12. Set the Output to Load in Browser.
    13. Scroll down to the "Additional Headers to Send" section.
    14. Add a custom header "Authorization: Bearer YOUR_BEARER_TOKEN"
    15. Add a Content-Type header "Content-Type:application/pdf"
    16. Add the variable you made earlier for "Content-Disposition:attachment; filename='"+PDF_Name_Variable +"'"
    17. 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

  • ✭✭✭✭✭✭
    edited 02/08/25

    This section of the Smartsheet API Documentation should help with the syntax:

    Site faviconSmartsheet - Official API and SDK Documentation

    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

  • 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:

    1. Create a Simple PDF variable.
    2. Load your PDF to this variable using the Load File action.
    3. Create a variable to store your PDF's name.
    4. Convert that variable using Evaluate Expression "Content-Disposition:attachment; filename='"+PDF_Name_Variable +"'"
    5. Do a text replace on this variable to replace ' with "
    6. Create a Call REST Web Service action.
    7. Configure this action with the URL "https://api.smartsheet.com/2.0/sheets/YOUR_SHEET_ID/rows/YOUR_ROW_ID/attachments"
    8. Set the Request Type to POST
    9. Specify raw body.
    10. Set the raw body to your Simple PDF variable.
    11. Set the content type to application/json.
    12. Set the Output to Load in Browser.
    13. Scroll down to the "Additional Headers to Send" section.
    14. Add a custom header "Authorization: Bearer YOUR_BEARER_TOKEN"
    15. Add a Content-Type header "Content-Type:application/pdf"
    16. Add the variable you made earlier for "Content-Disposition:attachment; filename='"+PDF_Name_Variable +"'"
    17. 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

Trending in API & Developers