SmartSheet API - Node.js SDK addRowUrlAttachment

What is the request body syntax when using the addRowUrlAttachment method in the Node SDK? The API documentation only shows an example using the addRowFileAttachment method.

Answers

  • Lee Joramo
    Lee Joramo ✭✭✭✭✭✭

    I have only uploaded file attachments via the API, and not used Links. And I am not on a system where I can test this, but my reading of the documents say that you would need to specify the attachmentType and maybe the fileName

    // Set options
     var options = {
      sheetId: 1696803624483716,
      rowId: 1049041355358596,
    "url": "https://example.com/my/myDocument.pdf", "attachmentType": "LINK", fileName: "myDocument.pdf" }; // Attach file to row smartsheet.sheets.addRowFileAttachment(options) .then(function(attachment) { console.log(attachment); }) .catch(function(error) { console.log(error); });

    If you are linking to files hosted in one of the specified services, you would need to alter the attachmentType. Dropbox would be "attachmentType": "DROPBOX"

  • That unfortunately doesn't work. I simply want to know what the arguments are for the addRowUrlAttachment method. "url" doesn't work because it alters the API URL route itself.

  • Isaac A.
    Isaac A. Employee

    Hi @Josh Rosenfeld!

    Currently, Smartsheet Support does not handle SDK-related inquiries. If you’ve tested and found an issue with the SDK, please report it on the relevant GitHub page. You can access the links to these pages in our API documentation here: Smartsheet API Documentation.

    Should you not get a response from the Community, consider checking out StackOverflow to connect with other developers to get more help.


    Cheers,

    Isaac.

    Join us at Smartsheet ENGAGE 2024🎉

    October 8 - 10, Seattle, WA | Register now

  • To add a URL attachment to a row in Smartsheet using the Node.js SDK, you can follow these steps:
    Install Smartsheet SDK:
    First, ensure you have the Smartsheet SDK for Node.js installed. You can do this via npm:

    npm install smartsheet

    Set Up Smartsheet Client:
    Initialize the Smartsheet client with your API token:

    const smartsheet = require('smartsheet');
    const client = smartsheet.createClient({ accessToken: 'YOUR_ACCESS_TOKEN' });

    Add a URL Attachment to a Row:
    You can add a URL attachment to a specific row using the addRowUrlAttachment function. Here’s an example:

    const sheetId = YOUR_SHEET_ID; // Replace with your sheet ID
    const rowId = YOUR_ROW_ID; // Replace with your row ID

    const attachment = {
    name: 'Example URL', // The name of the attachment
    description: 'Link to example', // Optional description
    attachmentType: 'LINK', // The type of attachment
    url: 'https://www.example.com' // The URL to attach
    };

    client.attachments.addRowUrlAttachment({ sheetId, rowId, attachment })
    .then(response => {
    console.log('Attachment added:', response);
    })
    .catch(error => {
    console.error('Error adding attachment:', error);
    });

    1. Explanation:
      • sheetId and rowId: These are the IDs of the sheet and row to which you want to add the URL attachment.
      • attachment object: This contains the details of the attachment including name, description, attachmentType, and url.

    By following these steps, you can easily add a URL attachment to a row in Smartsheet using the Node.js SDK. If you encounter any issues, make sure your API token and IDs are correct, and refer to the Smartsheet API documentation for more details.

    For further reference, you can check the Smartsheet API Documentation and the Node.js SDK GitHub repository.