Nextcloud Node - How to get the IDs of Folders and Files

Describe the problem/error/question

Hello all,

I need to get the IDs of Nextcloud Folders and Files to create correct Links and to sync the Data Structure between Nextcloud and a Database. Actually I can only create a Link, based of the Filesharing. But I want to avoid the Filesharing, because the Users are still logged in by Nextcloud and could open the Files without sharing.

When I use the Nextcloud Node I won’t get any IDs. Just eTags, who are not constant by changing the Folder/File. The other Information about the Folder/Files doesn’t care in this case.

Trying to use the HTTP-Node didn’t bring me forward. In Postman I get the IDs, but in the Node I don’t.

Postman:
PROPFIND https://your-nextcloud.com/remote.php/dav/files/wilano/projects

Body as Text:

<d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">
  <d:prop>
        <oc:fileid />
  </d:prop>
</d:propfind>

Response:

<?xml version="1.0"?>
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">
    <d:response>
        <d:href>/remote.php/dav/files/wilano/projects/</d:href>
        <d:propstat>
            <d:prop>
                <oc:fileid>82</oc:fileid>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
    </d:response>
    <d:response>
        <d:href>/remote.php/dav/files/wilano/projects/ProjectA/</d:href>
        <d:propstat>
            <d:prop>
                <oc:fileid>141</oc:fileid>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
    </d:response>
</d:multistatus>

In the HTTP Node the PROPFIND Call doesn’t exist. But when I import the curl Code from Postman, it will switch to PROPFIND but alerts me that the Value ist not supported.

The Response in the HTTP Node:

<?xml version="1.0"?>\n<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns"><d:response><d:href>/remote.php/dav/files/wilano/projects/</d:href><d:propstat><d:prop><d:getlastmodified>Tue, 26 Sep 2023 06:41:31 GMT</d:getlastmodified><d:resourcetype><d:collection/></d:resourcetype><d:quota-used-bytes>408037</d:quota-used-bytes><d:quota-available-bytes>-3</d:quota-available-bytes><d:getetag>&quot;65127d1bba144&quot;</d:getetag></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response><d:response><d:href>/remote.php/dav/files/wilano/projects/ProjectA/</d:href><d:propstat><d:prop><d:getlastmodified>Tue, 26 Sep 2023 06:41:31 GMT</d:getlastmodified><d:resourcetype><d:collection/></d:resourcetype><d:quota-used-bytes>408037</d:quota-used-bytes><d:quota-available-bytes>-3</d:quota-available-bytes><d:getetag>&quot;65127d1bba144&quot;</d:getetag></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response></d:multistatus>\n

Ok, the Body in the Node wasn’t pasted correctly. So I changed the Body value from:

<d:propfind xmlns:d

To:

<d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">
  <d:prop>
        <oc:fileid />
  </d:prop>
</d:propfind>

Response:

<?xml version="1.0"?>\n<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns"><d:response><d:href>/remote.php/dav/files/wilano/projects/</d:href><d:propstat><d:prop><d:getlastmodified>Tue, 26 Sep 2023 06:41:31 GMT</d:getlastmodified><d:resourcetype><d:collection/></d:resourcetype><d:quota-used-bytes>408037</d:quota-used-bytes><d:quota-available-bytes>-3</d:quota-available-bytes><d:getetag>&quot;65127d1bba144&quot;</d:getetag></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response><d:response><d:href>/remote.php/dav/files/wilano/projects/ProjectA/</d:href><d:propstat><d:prop><d:getlastmodified>Tue, 26 Sep 2023 06:41:31 GMT</d:getlastmodified><d:resourcetype><d:collection/></d:resourcetype><d:quota-used-bytes>408037</d:quota-used-bytes><d:quota-available-bytes>-3</d:quota-available-bytes><d:getetag>&quot;65127d1bba144&quot;</d:getetag></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response></d:multistatus>\n

Also switching the Authentication to Predefined Credential Type brings the same response.

What can I do? Without getting the IDs, Nextcloud is not practicable for my Project. But thats the only Issue - the other Features are still fine.

Please share your workflow

Share the output returned by the last node

<?xml version="1.0"?>\n<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns"><d:response><d:href>/remote.php/dav/files/wilano/projects/</d:href><d:propstat><d:prop><d:getlastmodified>Tue, 26 Sep 2023 06:41:31 GMT</d:getlastmodified><d:resourcetype><d:collection/></d:resourcetype><d:quota-used-bytes>408037</d:quota-used-bytes><d:quota-available-bytes>-3</d:quota-available-bytes><d:getetag>&quot;65127d1bba144&quot;</d:getetag></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response><d:response><d:href>/remote.php/dav/files/wilano/projects/ProjectA/</d:href><d:propstat><d:prop><d:getlastmodified>Tue, 26 Sep 2023 06:41:31 GMT</d:getlastmodified><d:resourcetype><d:collection/></d:resourcetype><d:quota-used-bytes>408037</d:quota-used-bytes><d:quota-available-bytes>-3</d:quota-available-bytes><d:getetag>&quot;65127d1bba144&quot;</d:getetag></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response></d:multistatus>\n

Information on your n8n setup

  • n8n version: 1.7.1
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Debian 11.7

I think I could find the issue. The Request Method “PROPFIND” is not an known value by the HTTP Node. In the code of that node (V3) I found an “if” line who checks the method parameter.

if (sendBody && ['PATCH', 'POST', 'PUT', 'GET'].includes(requestMethod)) { ......

so if the method doesn’t match, the body won’t sent with the request I guess?

Is there any workaround or other solution to solve this? Maybe I could modify the node file. But where is that file stored? And on every n8n update I have to repeat the workaround.

I could find the path of that file and added “PROPFIND” as option and added it in the “if” line.

Response is as expected with the needed FileIDs.

Do I need to create a Feature Request for adding the PROPFIND method in the HTTP Node?

1 Like

Hi @wilano, you’re quite right with your assumption I am afraid. The HTTP Request node does not support all WebDAV methods as of now, but perhaps you want to leave a vote on the respective feature request over here instead of raising a new one?

As a workaround, you could make your HTTP request through the this.helpers.httpRequest method in the Code node. For example like so:

1 Like

Hi @MutedJam , thanks for your suggestion. I tried your code example and it works as well. That should be better for n8n updates in the future.

Your proposed feature request I leaved a vote.

Thanks for help and have a nice weekend :slight_smile:

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.