Consume Nextcloud webdav API via user credentials

I would like to upload a document via API by providing my user credentials. I’m using axios as my http client.

So I followed this

and came up with the following NodeJs code, unfortunately I can’t test the upload function because I’m struggling with the session flow. The login response returns a 404. How do I sign in correctly? And where do I have to provide my credentials? This application is not a Nextcloud app, it’s just a basic API consumer.

import { readFileSync } from "fs";
import axios from "axios";

async function bootstrap() {
  try {
    // ### Login ###

    const tokenResponse = await"");
    const { poll, login } =;
    const { token, endpoint } = poll;
    const loginResponse = await, { token }); // !! returns 404 !!
    const { server, loginName, appPassword } =;

    // ### Uploading a new file ###

    const fileContent: Buffer = readFileSync("./test.csv");
    await axios.put("", fileContent);
  } catch (error) {
    throw error;

Thanks for help

Login flow will start a process to create a app password ( for all the details).

If you just want to upload a file it’s probably enough to pass username and password (a manually created app password is probably better) as auth to axios.

  auth: {
    username: 'janedoe',
    password: 's00pers3cret'