Hi, I use API in nodejs with class espocrm-api-client.js for upload attachment to task.
var payload = {
name: pdfName + ".pdf", => variable pdf name
type: "application/pdf",
role: "Attachment",
parentType: "Task",
parentId: task, => variable with task id
field: "attachments",
f ile: "data:application/pdf;base64,"+pdf64 => variable with pdf encode
};
client.request('POST', 'Attachment', payload)
.then(
(response) => {
/ / success
console.log('Respuesta subir Pdfffffffffffffffffffffffffffffffff');
console.log(response);
}
)
.catch(
(res) => {
// error
console.log(res.statusCode, res.statusMessage);
}
);
The attachment is saved correctly, but is not related to the task, check in the database and the fields parent_id and parent_type are null
{
id: '5ebc8b801c975f092',
name: '5e6918844b160ac1e.pdf',
deleted: false,
type: 'application/pdf',
size: 18129,
field: 'attachments',
createdAt: '2020-05-14 00:06:24',
role: 'Attachment',
storage: null,
storageFilePath: null,
global: false,
relatedName: null,
createdById: '5d30f8d6272b0215d',
createdByName: 'rootapi'
}
What am i doing wrong? Can you help me?
var payload = {
name: pdfName + ".pdf", => variable pdf name
type: "application/pdf",
role: "Attachment",
parentType: "Task",
parentId: task, => variable with task id
field: "attachments",
f ile: "data:application/pdf;base64,"+pdf64 => variable with pdf encode
};
client.request('POST', 'Attachment', payload)
.then(
(response) => {
/ / success
console.log('Respuesta subir Pdfffffffffffffffffffffffffffffffff');
console.log(response);
}
)
.catch(
(res) => {
// error
console.log(res.statusCode, res.statusMessage);
}
);
The attachment is saved correctly, but is not related to the task, check in the database and the fields parent_id and parent_type are null
{
id: '5ebc8b801c975f092',
name: '5e6918844b160ac1e.pdf',
deleted: false,
type: 'application/pdf',
size: 18129,
field: 'attachments',
createdAt: '2020-05-14 00:06:24',
role: 'Attachment',
storage: null,
storageFilePath: null,
global: false,
relatedName: null,
createdById: '5d30f8d6272b0215d',
createdByName: 'rootapi'
}
What am i doing wrong? Can you help me?
Comment