0

Download attachement to Local drive ##

        for(Row r : rows){

        PagedResult<Attachment> attachments = smartsheet.sheetResources().rowResources().attachmentResources().getAttachments(sheetId, r.getId(), null);


        System.out.println("attachments"+attachments.getData().size());


        if(attachments.getData().size() > 0){

        for(Attachment at : attachments.getData()){

                      System.out.println(String.format("Attachement ID[%s], URL{%s}",at.getId(),at.getUrl()));

        }

Output::

  • Attachement ID[2625191160375172], URL{null}
  • Attachement ID[3215061968807812], URL{null}
  • Attachement ID[6310196327802756], URL{null}
  • Attachement ID[5565993922652036], URL{null}
  • I want to download attachement associated with row, sheet or anything. i have trial account but i don't think that would be the problem. – Uzair Kamal May 27 '17 at 11:37
  • According to official [documentation](https://smartsheet-platform.github.io/api-docs/#get-attachment) GET /sheets/{sheetId}/attachments/{attachmentId} Fetches the Attachment specified in the URL. Access Scope READ_SHEETS Headers Authorization: Bearer ACCESS_TOKEN Returns Attachment object. For File attachments, this will include a temporary URL for downloading the file. Currently, the temporary URL is set to expire in 120000 milliseconds, or 2 minutes. – Uzair Kamal May 27 '17 at 12:36

1 Answers1

0

I understand now, iterating the object and reaching out the attachement will not give you the url, infact you have to get id from that object and then query smart sheet again with GetAttachment procedure i. e

  Attachment at = smartsheet.sheetResources().attachmentResources().getAttachment(sheetId, att.getId());