Question

I am executing code in a program I have been working on that uploads files to sharepoint. I am uploading the file with HTTP PUT, then using the path to update the attributes. For a day or two I've been focusing on user defined content types. Today I went to upload a file to the Document content type and I got an error that said The file or folder name contains characters that are not permitted.

My xml that is sent to UpdateListItems looks like this:

<Batch OnError="Continue">
  <Method ID="1" Cmd="Update">
    <Field Name="ID" />
    <Field Name="FileRef">http://sharepoint:32667/personal/user/Shared%20Documents/EmailMessage.msg</Field>
    <Field Name="ContentType">Document</Field>
    <Field Name="Title">Test</Field>
  </Method>
</Batch>

So far I have been successfull updating items. The only difference I can think of in this case is that the File path has the port number in it. I've been uploading to another server that I haven't had to specify the port number on.

The response I get back is:

<Results xmlns="http://schemas.microsoft.com/sharepoint/soap/">
  <Result ID="1,Update">
    <ErrorCode>0x81020073</ErrorCode>
    <ErrorText>The file or folder name contains characters that are not permitted.  Please use a different name.</ErrorText>
  </Result>
</Results>

Any ideas?

This is part of generalized code that will allow a user to pick a content type from a list. So that is why the content type gets set to Document. I'm guessing either that or the semicolon in the url may be the problem.

Était-ce utile?

La solution

The problem is that you are using a filepath that is URL encoded (the %20 should be a space):

<Batch OnError="Continue">
  <Method ID="1" Cmd="Update">
    <Field Name="ID" />
    <Field Name="FileRef">http://sharepoint:32667/personal/user/Shared Documents/EmailMessage.msg</Field>
    <Field Name="ContentType">Document</Field>
    <Field Name="Title">Test</Field>
  </Method>
</Batch>

You can use System.Web.HttpUtility.UrlDecode(filename) to help decode URLs.

Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top