_client.IsExistingObject(webdav URL of folder) returns false when i try to search folder with name "." and "/" which already exists in the folder where i am searching
-
2Can you please elaborate on sometime, looking at question it seems always.– Hiren KakuCommented Jan 4, 2017 at 7:24
-
3. and / are not valid characters in webdav file names, so they must be escaped. See here for more details: blogs.msdn.microsoft.com/robert_mcmurray/2011/04/27/…– Nuno Linhares ♦Commented Jan 4, 2017 at 13:55
2 Answers
Are you escaping your WebDAV URLs correctly? Try loading your folder by ID and checking it's locationInfo.WebDavUrl
property to make sure you are.
e.g:
//created a test folder named "testfolderwith/slashesand.dots"
var folder = (FolderData)client.Read("tcm:233-49109-2", new ReadOptions {
LoadFlags = LoadFlags.WebDavUrls
});
var webDavUrl = folder.LocationInfo.WebDavUrl;
// "/webdav/Test%20Publication/Building%20Blocks/testfolderwith%2Fslashesand%2Edots"
var unEscapedTest = client.IsExistingObject("/webdav/Test Publication/Building Blocks/testfolderwith/slashesand.dots");
// False
var escapedTest = client.IsExistingObject("/webdav/Test%20Publication/Building%20Blocks/testfolderwith%2Fslashesand%2Edots");
// True
We found out that actually this is a bug in system. We contacted SDL customer support and they verified that its indeed so. For example, if folder has dot in its name (.), IsExistingObject will return false even if folder exists.
They suggested to us to use encoding the period (.) . with %2E . We did so by creating overload method for HttpUtility.UrlEncode() where we additionally encode dot character.
Hope this helps :)
-
1Happy you got it working, but I disagree with your conclusion that it is a defect. Unescaped . is not valid in WebDAV URL, so the system returning false is the correct response - it cannot find an item with that URL.– Nuno Linhares ♦Commented Jan 28, 2017 at 19:25