Skip to main content

Hello, I’m trying to upload files using api (application/pdf), and I have several problems but focus on current. I’m making an api call using graphql api as it is said there, but my response.body is always ReadableStream and when I tried to read that stream a got the Uint8Array. Am I doing something wrong or it is what it sould be and I just can’t figure out how to get that url

Hi @dawid-szemborowski . What you describe with ReadableStream and Uint8Array probably means you are using JavaScript/NodeJS, correct? The issue certainly lies within your code rather than the API, as the API has no possiblity to change the type you get. Would you mind sharing thre respective code or possibly read some more on how to get the data from a ReadableStream?


Hi @dawid-szemborowski . What you describe with ReadableStream and Uint8Array probably means you are using JavaScript/NodeJS, correct? The issue certainly lies within your code rather than the API, as the API has no possiblity to change the type you get. Would you mind sharing thre respective code or possibly read some more on how to get the data from a ReadableStream?

yes, I’m using Javascript, but when I try to use my code locally, I get the ReadableStream, now I deployed the same code and I get the proper response. Only userMutationId is <nil>, should it be like that?


@dawid-szemborowski yes, userMutationId is a value you can use to verify the data integrity: pass it as an input and you should get it back as an output. If you do not give it as input, you get null back.


Hi @dawid-szemborowski . What you describe with ReadableStream and Uint8Array probably means you are using JavaScript/NodeJS, correct? The issue certainly lies within your code rather than the API, as the API has no possiblity to change the type you get. Would you mind sharing thre respective code or possibly read some more on how to get the data from a ReadableStream?

Ok now I think I’m almost there, but I have a little problem with attaching a file. I already created presigned url, then I uploaded the file, and I’m trying to create a card with my file, but I all the time get the same error:

{
data: { createCard: null },
errors: o
{
message: 'Invalid input: attach_your_resume (u"/orgs/9b72f885-4aa9-4d56-ba43-32748fa3e634/uploads/595dd766-c6b6-43a1-b7b2-bd4a4c124101/a.pdf"])',
locations: oArray],
path: aArray],
code: 30000,
type: 'PipefyRuntimeError'
}
]
}

and this is my graphql field attribute

{
field_id: "attach_your_resume",
field_value: "${`/orgs/9b72f885-4aa9-4d56-ba43-32748fa3e634/uploads/595dd766-c6b6-43a1-b7b2-bd4a4c124101/a.pdf`}"
}

 


I am not sure I understand what you mean by “graphql field attribute”. Is this the input to `

updateCardField

`?

I believe, given these informations, that you should have your `field_value` be an array, meaning your input to look like:

mutation {
updateCardField(input: {card_id: 123, field_id: "attach_your_resume", new_value: u"/orgs/9b72f885-4aa9-4d56-ba43-32748fa3e634/uploads/595dd766-c6b6-43a1-b7b2-bd4a4c124101/a.pdf"]}) {
clientMutationId
success
}

(note the square brackets as the main difference to yours). See also here:

https://community.pipefy.com/ask-a-question-78/how-do-i-use-an-api-uploaded-file-as-an-e-mail-attachment-using-the-api-983


I am not sure I understand what you mean by “graphql field attribute”. Is this the input to `

updateCardField

`?

I believe, given these informations, that you should have your `field_value` be an array, meaning your input to look like:

mutation {
updateCardField(input: {card_id: 123, field_id: "attach_your_resume", new_value: u"/orgs/9b72f885-4aa9-4d56-ba43-32748fa3e634/uploads/595dd766-c6b6-43a1-b7b2-bd4a4c124101/a.pdf"]}) {
clientMutationId
success
}

(note the square brackets as the main difference to yours). See also here:

https://community.pipefy.com/ask-a-question-78/how-do-i-use-an-api-uploaded-file-as-an-e-mail-attachment-using-the-api-983

no, it’s createCard, but I tried using an array and still doesn’t work

 


res = await fetch('https://api.pipefy.com/graphql', {
...auth,
body: JSON.stringify({
query: `
mutation {
createCard(input:{
pipe_id: "*pipe_id*",
phase_id: "*phase_id*",
title: "${name}",
fields_attributes: [{
field_id: "your_name",
field_value: "${name}",
},{
field_id: "email",
field_value: "${email}",
},{
field_id: "phone",
field_value: "${phone}",
},{
field_id: "attach_your_resume",
field_value: "${cvUrl}"
},{
field_id: "why_are_you_applying_for_this_job",
field_value: "${message}",
},{
field_id: "available_to_work_from",
field_value: "${availableFrom}",
},
{
field_id: "tech_stack",
field_value: "${techStack}",
},{
field_id: "position",
field_value: "${links}",
}
]
}) {
card {
id
}
}
}
`,
}),
})

 


Hmm. I see. Then I am sorry, I do not see any immediate mistake anymore. The possibilities I see, just to try and triage the issue, would be

  1. to not set the attachement on upload, but set it afterwards using the updateCardField.
  2. to set the attachment only or too on the input’s `attachments` property.
  3. Ping @Marcos Carvalho to ask him for help.

Hmm. I see. Then I am sorry, I do not see any immediate mistake anymore. The possibilities I see, just to try and triage the issue, would be

  1. to not set the attachement on upload, but set it afterwards using the updateCardField.
  2. to set the attachment only or too on the input’s `attachments` property.
  3. Ping @Marcos Carvalho to ask him for help.
  1. returns the same error
  2. how to achieve that? I tried but it returned me an error
  3. Ping @Marcos Carvalho 

2: errors:
    {
      message: 'Invalid input: attachment (m"/orgs/9b72f885-4aa9-4d56-ba43-32748fa3e634/uploads/236d13f4-ed98-4bc1-acd9-cdcb9e278ad0/pudzian%20%20%20%20%20%20.pdf"])',
      locations: cArray],
      path: Array],
      code: 30000,
      type: 'PipefyRuntimeError'
    }

]


One more thing I just noticed: did you always use “/orgs/...”, or did you also try without the first slash? I believe the correct way is without, i.e.

o"orgs/9b72f885-4aa9-4d56-ba43-32748fa3e634/uploads/236d13f4-ed98-4bc1-acd9-cdcb9e278ad0/pudzian%20%20%20%20%20%20.pdf"]

or

o"uploads/236d13f4-ed98-4bc1-acd9-cdcb9e278ad0/pudzian%20%20%20%20%20%20.pdf"]

 


One more thing I just noticed: did you always use “/orgs/...”, or did you also try without the first slash? I believe the correct way is without, i.e.

o"orgs/9b72f885-4aa9-4d56-ba43-32748fa3e634/uploads/236d13f4-ed98-4bc1-acd9-cdcb9e278ad0/pudzian%20%20%20%20%20%20.pdf"]

or

o"uploads/236d13f4-ed98-4bc1-acd9-cdcb9e278ad0/pudzian%20%20%20%20%20%20.pdf"]

 

starting with /orgs, orgs, /uploads or uploads, everything doesn’t work


Reply