Following example code:
const projectGID = ‘1171144249301681’;
const statusResult = await asanaClient.projectStatuses.createProjectStatusForProject(
projectGID,
{
color: ‘green’,
text: ‘test’,
title: ‘test title’
}
);
console.log(‘statusResult’, statusResult);
We created a new status update,
to ensure all is good, we fetch it now again:
const statusUpdate = await asanaClient.projectStatuses.getProjectStatus(
statusResult.gid
);console.log(‘statusUpdate’, statusUpdate);
all good, we have a new status update in place.
great, now we add an attachment:
const paramsUpload = {
method: ‘POST’,
url:https://app.asana.com/api/1.0/tasks/${statusUpdate.gid}/attachments
,
formData: {
file: {
value: fs.readFileSync(‘img.jpg’),
options: {
filename: ‘test’
}
}
},
headers: {
‘Content-Type’: ‘multipart/form-data’
}
};
await asanaClient.dispatcher.dispatch(paramsUpload, {});
wow, also this worked! You can see the attachment in the status update now perfect!
And now we want to get all attachments that are assoicated with this status update:
const params = {
method: ‘GET’,
url:https://app.asana.com/api/1.0/tasks/${statusUpdate.gid}/attachments
};
const res = await asanaClient.dispatcher.dispatch(params, {});
or via client direclty:
const res = await asanaClient.attachments
.getAttachmentsForTask(statusUpdate.gid);
… not working … Api says it does not recognize the ID?
{“errors”:[{“message”:“task: Not a recognized ID: 1198849200704702”,“help”:“For more information on API status codes and how to handle them, read the docs on errors: Build an app with Asana”}]}
Uploading works with the GID though, therefore I assume this is an API bug!?
Thanks
Simon