This project has moved. For the latest updates, please go here.

GetItem functionality to get the stream of attachments not working

Aug 29, 2016 at 4:06 PM
Edited Aug 29, 2016 at 4:09 PM
Hello,

I am trying to copy list items including attachments from one list to another. In order to copy the attachments, I thought I would use the GetItem functionality to get the attachment item stream and then use AddAttachment to add it to the other list. However, GetItem functionality returns no stream for attachment urls. The response received back is <GetItemResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/"><GetItemResult>0</GetItemResult></GetItemResponse>. And my request looks something like this:

$().SPServices({
operation: "GetItem",
Url: location.protocol+"//"+location.host+"/"+pathtosite+"/Lists/"+listname+"/Attachments/"+itemid+"/test.docx"
});

Interestingly, I do get the Stream back if I supply a url pointing to a document in document library.

We are on SharePoint 2007. Any help appreciated. Thank you.
Coordinator
Aug 29, 2016 at 6:29 PM
Call GetAttachmentCollection to get the URLs, and then go from there...

M.
Aug 29, 2016 at 7:48 PM
Hello,

Sorry, I failed to mention it. GetAttachmentCollection is what I have been using to get the attachment urls. But when it was not working, I tried using a manually supplied attachment URL to see if I could get to the stream using GetItem. And that's when I posted this discussion. So, GetAttachmentCollection also returns the same exact attachment url that I manually supplied in the original post but GetItem will not fetch the item stream for attachments.

Thank you.
Coordinator
Sep 1, 2016 at 10:36 PM
Once you have the URL to the attachment, you can open the file at that location and read it. You don;t get a stream from any of these services: you need to open the file yourself.

M.