Solved

How can I upload or remove an attachment using API?

  • 24 July 2020
  • 6 replies
  • 1328 views

Userlevel 3

It's possible to upload a file and create and/or delete attachments in pipes using GraphQL API?

icon

Best answer by Marcos Carvalho 3 August 2020, 22:22

View original

6 replies

Userlevel 3

I'm almost there… But near of giving up. :expressionless:

 

Create a pre-signed URL and get the output url to send a PUT request with the attachment, using Postman. It worked and I can download the file using the downloadurl, which is also responded from the API. Ref. https://api-docs.pipefy.com/reference/mutations/createPresignedUrl/

mutation {
createPresignedUrl(input: {fileName: "teste.pdf", organizationId: <orgid>},) {
clientMutationId
downloadUrl
url
}
}

 

Update the attachment field of the card. In this case we need to get the part of downloadedurl starting from "upload/…". Ref. https://api-docs.pipefy.com/reference/mutations/updateFieldsValues/

mutation {
updateFieldsValues(input: {nodeId: <cardid>, values: {fieldId: "<field_attachment>", value:["uploads/63c330ba-9747-456d-8862-f616436ea1e8/teste.pdf"], operation: ADD}}) {
clientMutationId
}
}

 

I can see the attachment correctly in the card, but I'm not able to download. Should be something wrong with the signature or something. I'm not sure what is the "_ga" parameter after the filename when we download the file.

https://app-storage-service.pipefy.com/v1/resources/cards-v1/<cardid>/uploads/63c330ba-9747-456d-8862-f616436ea1e8/teste.pdf?_ga=2.64867503.1802465779.1595852158-1759315231.1595509439

The link responded with 404. 

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>uploads/63c330ba-9747-456d-8862-f616436ea1e8/teste.pdf</Key><RequestId>6F758D5B364181CF</RequestId><HostId>+ROfSzuvXkZ6X+5UmJ+vvfAftdSmY1z89ZCu93heA869+wXqrJFLsPha1T54Gzy17UkAVsGGazE=</HostId></Error>

:angry:

Userlevel 6
Badge +6

Hey Michel, 

 

You are almost there. Before updating the field with the presigned URL you need to transfer the file to our S3 bucket. 

 

But this feature is only available on Enterprise features plan where there’s a lot of other nice tools to help you out. 

 

Feel free to contact us to know more about it. 

Userlevel 3

That's very interesting.

In the comparison table I didn't note any specific feature related to that (my plan is Business). Besides, I can access the same API methods in order to get the signed URL and upload the files. The issue here is how to link that like with attachments properties.

 

Userlevel 3

Thanks for you answer.

Now we are clear to move on to another tool for that specific purpose.

 

Good Morning,

I’m still having this issue but my plan is Enterprise Tier I.
I went throught the 3 steps mentioned by Michel:

1 - Sent the mutation to createPresignedUrl and fetched both the downloadUrl and url

2 - Using the url provided, I sent a PUT request through Postman containing my PDF file (received status 200)

3 - I sent the updateFieldsValues mutation passing the value like: “uploads/<id_received>/<filename>.pdf” and the attachment appears correct on the card. However, I’m also unable to download it (status 404) 

 

Can anyone please help me? I’m not sure if I’m passing the correct string on the updateFieldsValues mutation value 

I'm almost there… But near of giving up. :expressionless:

 

Create a pre-signed URL and get the output url to send a PUT request with the attachment, using Postman. It worked and I can download the file using the downloadurl, which is also responded from the API. Ref. https://api-docs.pipefy.com/reference/mutations/createPresignedUrl/

mutation {
createPresignedUrl(input: {fileName: "teste.pdf", organizationId: <orgid>},) {
clientMutationId
downloadUrl
url
}
}

 

Update the attachment field of the card. In this case we need to get the part of downloadedurl starting from "upload/…". Ref. https://api-docs.pipefy.com/reference/mutations/updateFieldsValues/

mutation {
updateFieldsValues(input: {nodeId: <cardid>, values: {fieldId: "<field_attachment>", value:["uploads/63c330ba-9747-456d-8862-f616436ea1e8/teste.pdf"], operation: ADD}}) {
clientMutationId
}
}

 

I can see the attachment correctly in the card, but I'm not able to download. Should be something wrong with the signature or something. I'm not sure what is the "_ga" parameter after the filename when we download the file.

https://app-storage-service.pipefy.com/v1/resources/cards-v1/<cardid>/uploads/63c330ba-9747-456d-8862-f616436ea1e8/teste.pdf?_ga=2.64867503.1802465779.1595852158-1759315231.1595509439

 

 

Userlevel 4

Hey Michel, 

 

You are almost there. Before updating the field with the presigned URL you need to transfer the file to our S3 bucket. 

 

But this feature is only available on Enterprise features plan where there’s a lot of other nice tools to help you out. 

 

Feel free to contact us to know more about it. 

Hi Marcos how are you?

How do I do that?

Reply