Hi, I’m trying to programmatically upload a file as a new version.
What I have so far:
var boardId = 25509xxxxx;
var itemId = 25509xxxxx;
var assetId = 4888xxxxx;
const uploadQuery =
`
	mutation ($file: File!) {
		add_file_to_column (item_id: ${itemId}, column_id: "files", file: $file) {
			id
		}
	}
`;
var url = "https://api.monday.com/v2/file";
var buf = fs.readFileSync("./package.json");
var formData = new  FormData();
formData.append("query", uploadQuery, { contentType:  "application/json" });
formData.append("variables[file]", buf, { contentType:  "application/octet-stream", filename:  "package.json" });
var options = {
	method:  'post',
	headers:  formData.getHeaders(),
	body:  formData,
};
options.headers.Authorization = user.token;
var uploadResponse = await fetch(url, options);
var json = await  uploadResponse .json();
var jsonChange = JSON.stringify({
	updated_file:
	{
		fileType:  "ASSET",
		assetId:  json.data.add_file_to_column.id,
		previousAssetId:  assetId,
		name:  "package.json",
		isImage:  false,
		isVersion:  true,
	}
}).replace(/"/g,'\\\\"');
const  updateQuery =
`
mutation {
	change_column_value (board_id: ${boardId}, item_id: ${itemId}, column_id: "files", value: "${jsonChange}") {
		id
	}
}
`;
var updateResponse = await  monday.api(updateQuery, { token:  user.token });
And it works, except a file is duplicated in a column. I also tried to send removed_file with v1 asset id and it works. But after that you can’t access v1 anymore.
Is it a bug or am I doing something wrong?





