TDSE.GetObject doesn't resolve a WebDAV URL with dots in it
-
30-05-2021 - |
Question
Anyone experienced exception using below function?
tdse.GetObject(tmpFolderWebDavURL, EnumOpenMode.OpenModeView, null,
XMLReadFilter.XMLReadAll) as Folder;
Seems if the last segment of webdav contains a dot then the method throws and exception.
for example
tmpFolderWebDavURL = "/webdav/test_publication/2.2 folder name"
- fails exception thrown
tmpFolderWebDavURL = "/webdav/test_publication/22 folder name"
- works
tmpFolderWebDavURL = "/webdav/test_publication/2.2 folder name/sub_folder"
- works
Exception
<?xml version="1.0"?>
<tcm:Error xmlns:tcm="http://www.tridion.com/ContentManager/5.0" ErrorCode="80040200" Category="4" Source="Kernel" Severity="2">
<tcm:Line ErrorCode="80040200" Cause="false" MessageID="15301">
<![CDATA[Unable to get TOM object for URI: /webdav/TPMG Medical Library Content/Building Blocks/Content Live/2.2 People Lists]]>
<tcm:Token>/webdav/TPMG Medical Library Content/Building Blocks/Content Live/2.2 People Lists</tcm:Token>
</tcm:Line>
<tcm:Line ErrorCode="80040200" Cause="true" MessageID="15748">
<![CDATA[Unable to map all paths to URIs.]]>
</tcm:Line>
<tcm:Details>
<tcm:CallStack>
<tcm:Location>SystemDAL.GetURIsFromPaths</tcm:Location>
<tcm:Location>SystemDAL.GetURIsFromPaths</tcm:Location>
<tcm:Location>URLConversion.ConvertURLToURI</tcm:Location>
<tcm:Location>SystemBLST.IBLSystemST_ConvertURLToURI</tcm:Location>
<tcm:Location>TDSE.GetObject</tcm:Location>
</tcm:CallStack>
</tcm:Details>
</tcm:Error>
Solution
Just like with spaces, dots must be escaped in webdav URLs.
So a space becomes "%20", a dot becomes "%2E". Try doing tmpFolderWebDavURL.Replace(".", "%2E")
.
OTHER TIPS
This is another reason to have the powershell open whenever you are doing this kind of development.
Assuming you know the tcm uri of the item, you can get the correct WebDAVURL very easily:
> $tdse = new-object -com TDS.TDSE
> $sch = $tdse.GetObject("tcm:3-92723-8",1)
> $sch.info.WebDAVURL
/webdav/00_Schemas_003/Building%20Blocks/Schemas/Component/ComponentStaffItem.xsd
A quick copy-paste and you're done!
Instead of replacing "." with "%2E" its better to use Url Encoding. Tridion will decode the url while resolving the item from the webdav url.
Its always safe to use url encoding before sending that to Tridion.