When creating a new List or Library in SharePoint, or even creating a new Folder inside the list or library, the URL generated by SharePoint may not match the name entered by the user.

I need to programmatically construct the same URL as SharePoint from the same data a user might manually copy and paste into the Create dialog's textboxes, but I don't know the algorithm it uses.

I'm using K2 Studio to create workflows that integrate with SharePoint 2010. Management strongly prefers a no-code solution, but I do have access to Visual Studio and am willing to use it. With the hassles of connecting to a claims-authentication environment, I'd prefer any .Net code use K2's built-in features or not connect to SharePoint.


Example of problem:

Incoming data which a K2 Blackpearl workflow uses to create a new library: abc-123 (def@ghi.jkl). If that data is pasted into name field of SharePoint's "Create" dialog when creating a new list or library, many of the characters will be dropped from the resulting URL. The URL will probably end up like this: ...\abc123%20defghi.jkl. Similar (or even identical) logic is applied when a K2 Blackpearl workflow creates a new list or library in SharePoint.

I have not found any documentation for what characters are kept, which are dropped, and which get URL encoded. Without that knowledge, I cannot ensure that the URLs I attempt to construct from the same data used to construct the library names will actually match the URLs created by SharePoint.

Secondary question:

If the generated URL matches an existing URL, what does SharePoint do? Throw an error, append a counter? Something else?


If you create a list/library in the UI as MyList, the internal URL gets set as MyList. Users can go back later and rename it to My List for a better display, but it still remains MyList. If it is set as My List, it will be stored as My List, rendered as My%20List in the address bar of the browser.

Whatever you pass in on the initial create is what is stored. Users will generally not compact it and you should expect spaces in the value.

  • URL encoding of spaces does not cause a problem. However, SharePoint does a lot more than just encode spaces - it literally drops characters. So far, I know that hyhpens, forward and backward slashes, and parantheses get dropped. What other characters get dropped? Do any characters get converted to something else? Is there a list or some documentation? I've edited the question to better explain what I'm trying to do.
    – Zarepheth
    Jan 14 '13 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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