views:

728

answers:

2

Hi,

I have a SharePoint List to which I'm adding new ListItems using the Client Object Model. Adding ListItems is not a problem and works great.

Now I want to add attachments.

I'm using the SaveBinaryDirect in the following manner:

File.SaveBinaryDirect(clientCtx, url.AbsolutePath + "/Attachments/31/" + fileName, inputStream, true);

It works without any problem as long as the item that I'm trying to add the attachment to, already has an attachment that was added through the SharePoint site and not using the Client Object Model.

When I try to add an attachment to a item that doesnt have any attachments yet, I get the following errors (both happen but not with the same files - but those two messages appear consistently):

The remote server returned an error: (409) Conflict
The remote server returned an error: (404) Not Found

I figured that maybe I need to create the attachment folder first for this item. When I try the following code:

clientCtx.Load(ticketList.RootFolder.Folders);
clientCtx.ExecuteQuery();
clientCtx.Load(ticketList.RootFolder.Folders[1]);             // 1 -> Attachment folder
clientCtx.Load(ticketList.RootFolder.Folders[1].Folders);
clientCtx.ExecuteQuery();
Folder folder = ticketList.RootFolder.Folders[1].Folders.Add("33");
clientCtx.ExecuteQuery();

I receive an error message saying:

Cannot create folder "Lists/Ticket System/Attachment/33"

I have full administrator rights for the SharePoint site/list.

Any ideas what I could be doing wrong?

Thanks, Thorben

A: 

I have discussed this question with Microsoft. Looks like that only one way to create attachments remotely is List.asmx web service. I have tried to create this subfolder also and with no success.

MaxBeard
Thorben
A: 

Hi MaxBeard,

I am facing same problem of attachment as Thorben. As you have mentioned that it is not possible with Client Object Model. That is fine.

Can you give me some reliable link that you have found this limitation of Client Object Model?

So i can give it to my client for specification.

StackOverflow is reliable that i gave to my client but still they want some links from Microsoft or any other.

Thanks & Regards, shailesh

shailesh