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 axios.post("https://cloud.computech.de/index.php/login/v2");
const { poll, login } = tokenResponse.data;
const { token, endpoint } = poll;
const loginResponse = await axios.post(endpoint, { token }); // !! returns 404 !!
const { server, loginName, appPassword } = loginResponse.data;
// ### Uploading a new file ###
const fileContent: Buffer = readFileSync("./test.csv");
await axios.put("https://cloud.foo.com/remote.php/dav/files/myUsername/shared/test.csv", fileContent);
} catch (error) {
throw error;
}
}
bootstrap();
Thanks for help