Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have the following code which creates an item in the library I want:

string newPageXml = String.Format(@"<Batch OnError='Continue'>
                        <Method ID='1' Cmd='New'>
                            <Field Name='ID'>New</Field>
                            <Field Name='Title'>{0}</Field>
                            <Field Name='PublishingPageContent'>{1}</Field>
                            <Field Name='LinkFilenameNoMenu'>{2}</Field>
                        </Method>
                    </Batch>", "test.aspx",
                             Microsoft.SharePoint.Utilities.SPEncode.HtmlEncode(newPageContent),
                             "test.aspx");

XmlDocument xdPage = new XmlDocument();
xdPage.LoadXml(newPageXml);
newItem = xdPage.DocumentElement;
createdItem = ceoList.UpdateListItems("Pages", newItem);

But when the item is created it gets the ID for that item as the file name. So if the ID is 37 then the Name will be 37_.

I've tried DisplayName, LinkFilename, Name and a few other values but the ID always shows up at the name. What do I need to put in here to specify the file name?

If I can't use the list service, how can I use any of the web services to create a new item in the Pages library?

share|improve this question
    
Is there anyone out there? I've been banging my head against this seemingly simple problem for two days now and I'm about to loose it! –  Abe Miessler Jul 19 '12 at 17:34
    
Have you tried "BaseName" ? or "URL" ? –  PlanetWilson Jul 20 '12 at 13:27
    
I am not sure for MOSS, but you can try "FileLeafRef" for File name. May be it can help ! –  J.Shah Jul 24 '12 at 11:25
    
@abe Did you get this working? –  Amicable Jul 27 '12 at 8:07
    
Yes, I ended up using a combination of the copy and list service to get a complete solution. I'll post what I did any why I needed both for posterity. –  Abe Miessler Jul 27 '12 at 15:03
add comment

2 Answers

up vote 3 down vote accepted
+50

Lists.asmx is the wrong service to use. My head banging into the subject suggested that there are 3 ways to upload to Sharepoint:

  1. Copy.asmx web service
  2. WebDav
  3. Frontpage Rpc (Remote Control Procedures)

To summarise the first two are limited by Windows to file sizes around 2MB for reliable transmission (higher and you can get OutOfMemoryExceptions). This is because Windows must allocate byte arrays in continuous memory. Larger files need to be sent in fragments, which only RPC supports.

Also important to note, WebDav can't send MetaData at all (without support from web services) so it will be displayed as the default content type. If there are more than one content types, it will also remain checked out and invisible to users.

The RPC method Requires Frontpage Extension are installed on the Sharepoint server, which are shipped with Windows Server you just need to install the Windows Component.

This article was the best I could find off hand - it has examples for all three.

Some other articles:

Helper class for using Copy.asmx

Part 2: Helper class for RPC

Edit: FrontPage RPC with better explanation

share|improve this answer
1  
Had the same problem, Frontpage RPC is not the best documented way, but it works and let's you specify pretty much everything you want. I'd recommend it too. –  Jasper Jul 23 '12 at 8:32
add comment

I think for a publishing page you need to actually upload a "file" even though it isn't really a file as such. You can use the copy.asmx operation to take an existing page and set pretty much all the properties to create a new page - would that work?

http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/ca1b0312-c6d9-4ceb-a1dd-6909b458157b

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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