Access Attachments from List Item using REST API

In this blog, I am going to give some REST API endpoints to access the attachment files with its proeprties from List item:
 
To get all attachments from List Item:
  1. //Option 1    
  2. https://<SharepointSiteURL>/_api/web/lists/getByTitle('<ListName>')/getitembyid(<ItemID>)/attachmentfiles      
  3.     
  4. //Option 2    
  5. https://<SharepointSiteURL>/_api/web/lists/getByTitle('<ListName>')/Items(<ItemID>)/attachmentfiles     
To get specific attachment based on attachment file name:
  1. //Option 1:  
  2. https://SharepointSiteURL/_api/web/lists/getByTitle('<ListName>')/getitembyid(<ItemID>)/attachmentfiles('<filename.docx>')  
  3.   
  4. //Option 2:  
  5. https://SharepointSiteURL/_api/web/lists/getByTitle('<ListName>')/getitembyid(<ItemID>)/attachmentfiles/getbyfilename('<filename.docx>')  
To get the property from attachment file:
  1. https://SharepointSiteURL/_api/web/lists/getByTitle('<ListName>')/getitembyid(<ItemID>)/attachmentfiles('<filename.docx>')?$select=ServerRelativeUrl,FileName  
By adding to $select=ServerRelativeUrl, FileName works for all options provided above.
Ebook Download
View all
Learn
View all