Alvin Lau
Alvin Lau

Reputation: 194

Unable to access BigCommerce WebDAV using node.js

Things actually work if I access the BigCommerce WebDAV via Cyberduck. However, I want to do this programmatically. Therefore, I wrote these code:

const { createClient } = require("webdav");

async function run() {
    const client = createClient(
        "https://mystore.mybigcommerce.com/dav",

        {
            username: "[email protected]",
            password: "mypassword"
        }
    );

    const contents = await client.getDirectoryContents("/"); 
}

run();

This is my code to get directory contents. I copied it from https://github.com/perry-mitchell/webdav-client#usage. I copied the email and password from the BigCommerce site.

The computer returns (node:32672) UnhandledPromiseRejectionWarning: Error: Request failed with status code 401 after I ran the script.

If I enter the URL in the web browser and enter the correct username and password, it returns this:

<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
    <s:exception>Sabre\DAV\Exception\NotImplemented</s:exception>
    <s:message>
        There was no plugin in the system that was willing to handle this GET method. Enable the Browser plugin to get a better result here.
    </s:message>
</d:error>

Hope you guys can find out what is going on, thanks.

Upvotes: 1

Views: 470

Answers (1)

Karen White
Karen White

Reputation: 2153

You'll need a client that supports Digest Auth, not just Basic. Looks like there was some conversation about adding digest support to the WebDAV client you're using. This PR might be a good starting place:

https://github.com/perry-mitchell/webdav-client/pull/96

Upvotes: 2

Related Questions