3

I have a list with 3 lookup columns and some of the items have attachments in it. I need to get the list items using REST API with details about any attachments in the items.

When I try to run the below query, I do not get any attachment details, though they are there.

http://<SITE>/_api/web/lists/getbytitle('<LISTNAME>')/items?
$expand=AttachmentFiles,Lookup1,Lookup2,Lookup3&
$select=Lookup1/Title,Lookup2/Title,Lookup3/Title

But when I try to run the query with additional select for AttachmentFiles/FileName,AttachmentFiles/ServerRelativeUrl it throws me error.

http://<SITE>/_api/web/lists/getbytitle('<LISTNAME>')/items?
$expand=AttachmentFiles,Lookup1,Lookup2,Lookup3
&$select=Lookup1/Title,Lookup2/Title,Lookup3/Title,AttachmentFiles/FileName,AttachmentFiles/ServerRelativeUrl

Below is the error message that I receive.

<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code>-2147024809, System.ArgumentException</m:code>
<m:message xml:lang="en-US">
Column 'Attachments' does not exist. It may have been deleted by another user.
</m:message>
</m:error>

What am I doing wrong here?

Update 1:

I get same error with below query.

http://<SITE>/_api/web/lists/getbytitle('<LISTNAME>')/items?
$expand=AttachmentFiles,Lookup1,Lookup2,Lookup3
&$select=Lookup1/Title,Lookup2/Title,Lookup3/Title,AttachmentFiles
4
  • can you try it as http://<SITE>/_api/web/lists/getbytitle('Narrative%20Framework')/items? $select=Lookup1/Title,Lookup2/Title,Lookup3/Title,AttachmentFiles &$expand=AttachmentFiles,Lookup1,Lookup2,Lookup3 and check ? Aug 4, 2017 at 10:14
  • @GautamSheth: Tried it, but didn't work
    – Naveen
    Aug 4, 2017 at 10:20
  • sorry, Can you try it again as http://<SITE>/_api/web/lists/getbytitle('Narrative%20Framewo‌​rk')/items?$select=Lookup1/Title,Lookup2/Title,Lookup3/Title,Attachments,Attachment‌​Files&$expand=AttachmentFiles,Lookup1,Lookup2,Lookup3 and check ? Aug 4, 2017 at 10:26
  • @GautamSheth: That worked! If you can post this as answer then I will be happy to accept it as answer Also why is Attac‌​hment‌ required in select query?
    – Naveen
    Aug 5, 2017 at 11:16

1 Answer 1

3

Looks like you are missing the Attachments column in the API.

Try it as below:

http://<SITE>/_api/web/lists/getbytitle('Narrative%20Framewo‌​‌​rk')/items
?$select‌​=Lookup1/Title,Looku‌​p2/Title,Lookup3/Tit‌​le,Attachments,Attac‌​hment‌​Files
&$expand‌​=AttachmentFiles,Loo‌​kup1,Lookup2,Lookup3
1
  • Getting "Column 'Attachments' does not exist. It may have been deleted by another user." Using this Jan 19, 2020 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.