Hi,
I'm using version 1.0.0 of this library from Maven Central: https://mvnrepository.com/artifact/com.asana/asana/1.0.0
This is the latest version by the time of creating this ticket.
I have encountered an issue of not being able to attach files to Project Statuses via the client API. There is simply no such method to call.
The documentation of this part also seems to be a bit ahead of time, because it presents the following Java example which uses a method that is not (yet?) available in the client:
https://developers.asana.com/docs/upload-an-attachment
Attachment result = client.attachments.createAttachmentForObject(file, parent, url, name)
.data("field", "value")
.data("field", "value")
.option("pretty", true)
.execute();
Instead, what the client currently offers is only usable for attaching files to tasks:
|
public ItemRequest<Attachment> createOnTask(String task, InputStream fileContent, String fileName, String fileType) { |
I was able to work it around with the following class:
public class ExtendedAttachments extends Attachments {
public ExtendedAttachments(Client client) {
super(client);
}
public ItemRequest<Attachment> createOnProjectStatus(String projectStatus, InputStream fileContent,
String fileName, String fileType) {
return new ItemRequest<>(this, Attachment.class, "/attachments", "POST").data(
new MultipartContent()
.setMediaType(
new HttpMediaType(ContentType.MULTIPART_FORM_DATA.getMimeType()).setParameter(
"boundary",
UUID.randomUUID().toString()))
.addPart(new Part()
.setContent(new InputStreamContent(fileType, fileContent))
.setHeaders(new HttpHeaders().set(
CONTENT_DISPOSITION,
format("form-data; name=\"file\"; filename=\"%s\"", fileName)
)))
.addPart(new Part()
.setContent(new ByteArrayContent(null, projectStatus.getBytes()))
.setHeaders(new HttpHeaders().set(
CONTENT_DISPOSITION,
"form-data; name=\"parent\""
)))
);
}
}
Hi,
I'm using version
1.0.0of this library from Maven Central: https://mvnrepository.com/artifact/com.asana/asana/1.0.0This is the latest version by the time of creating this ticket.
I have encountered an issue of not being able to attach files to Project Statuses via the client API. There is simply no such method to call.
The documentation of this part also seems to be a bit ahead of time, because it presents the following Java example which uses a method that is not (yet?) available in the client:
https://developers.asana.com/docs/upload-an-attachment
Instead, what the client currently offers is only usable for attaching files to tasks:
java-asana/src/main/java/com/asana/resources/Attachments.java
Line 30 in d7281b0
I was able to work it around with the following class: