I’ve been trying to attach a file from a URL in file manager and from file manager to deal through engagement. Previously, I was trying to do this process using this endpoint
/filemanager/api/v3/files/upload
but I wan’t lucky enough to do my thing using that endpoint and posted a separate question for it on forum.
Now I’m trying to upload files from a url to file manager using this endpoint
/files/v3/files/import-from-url/async
In response I’m getting
{“id”:“AAAADKf-yqU”,“links”:{“status”:“https://api.hubspot.com/files/v3/files/download-from-url/AAAADKf-yqU/status”}}
Now I’m confused about this response because of two reasons
- status link in the response is not working and returning 404 Not Found
- If I’ve to attach this specific file with the engagement how can I do it because engagement takes attachment id of file not the id I’m getting in the response.
This is my code
var options = {
"method": "POST",
"hostname": "api.hubapi.com",
"port": null,
"path": "/files/v3/files/import-from-url/async?hapikey=demo",
"headers": {
"accept": "application/json",
"content-type": "application/json"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
console.log(body)
});
});
req.write(JSON.stringify({
access: 'PUBLIC_INDEXABLE',
ttl: 'P3M',
name: 'test image',
url: "https://app.arrivy.com/api/files/AMIfv95pvfFG9Yvgxx2LVLTv7BFfIwsfRjeGXeQjUQYhlB3ul32Bwc86NYYR2uKcUXfv0KRoVwIwPCDy3sAaww3Msra-Kg4oZJsa9GgYVQIxjgNPMi1vRmmlnRQswrHQ2IDq3cRfGHY0Fcp62ocnsdq-d_772HWono9AyWYd6NOiAKbBhCUi95TYC0S74OPY6itN6owPt6MxU8TkuV1WR7UOgsVFVPjmjrt8ZVdHE1gF3Wi9epodApJ7Vgtswhhrfy7hqrCdXO5hsY2uTQtiXuTbu2SqYEurO8fOLBIbePjhjy4gmAyEiJuGgLYHcexNlUdRdWwwbjP68tgVgCanSDCfTmvWPhmwh9JPlykbunb194kfX2XQtWk",
folderPath: 'docs',
duplicateValidationStrategy: 'NONE',
duplicateValidationScope: 'ENTIRE_PORTAL',
overwrite: true
}));
req.end();
``