Skip to main content

Hello,

I'm trying to send a file to a card. Executing createPresignedUrl and PUT for S3 works perfectly, I can even access the download of the file that was sent.

My problem is with the updateFieldsValues mutation. When I send it I get an error, can you help me with that?

 

My mutation:


mutation {
updateFieldsValues(
input: {
nodeId: CARD-ID,
values: {
fieldId: "foto_do_cnpj_cpf",
value: "uploads/7c3b7885-16d5-44c0-9e23-8570f261b20a/1633126573430.png"],
operation: ADD
}
}
)

{
clientMutationId,
updatedNode
}
}

 

The returned error:

 

{
"data": {
"updateFieldsValues": null
},
"errors": "
{
"message": "Invalid input: foto_do_cnpj_cpf (f\"uploads/7c3b7885-16d5-44c0-9e23-8570f261b20a/1633126573430.png\"])",
"locations": "
{
"line": 3,
"column": 7
}
],
"path": "
"updateFieldsValues"
],
"code": 30000,
"type": "PipefyRuntimeError"
}
]
}

 

Do you know what it can be? I've already checked the field id, it's correct

@dawid-szemborowski  reports a similar problem in

https://community.pipefy.com/api-76/createpresignedurl-returns-readablestream-1264

 

I do have a script where I got the upload working. The difference in the updateCardField query compared to yours is the includsion of the “orgs/...” part of the URL.

 

Below, I post my (PHP) function so you can compare it to yours, as I do not see the rest of your code.

 

<?php

use GraphQL\Client;
use GraphQL\Exception\ArgumentException;
use GraphQL\Exception\InvalidSelectionException;
use GraphQL\Exception\QueryError;
use GraphQL\Mutation;
use GraphQL\Query;
use GraphQL\RawObject;

// namespace, class, functions omitted

function uploadFile(string $filePath, string $fileName, int $cardId, string $fieldId, string $contentType)
{

$targetFileName = preg_replace("/p^a-zA-Z0-9_\-\.]+/", '_', $fileName);

// Fetch the URL to upload to
$mutation = (new Mutation('createPresignedUrl'))->setArguments(g'input' => new RawObject('{
organizationId: "' . self::ORGANIZATION_ID . '",
fileName: "' . addslashes($targetFileName) . '",
contentType: "' . addslashes($contentType) . '"
}')])->setSelectionSet(t'clientMutationId', 'url']);

// DO UPLOAD
$presignedUrlResults = $this->runGraphQLQuery($mutation);
$presignedUrl = $presignedUrlResultsl'createPresignedUrl']n'url'];

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $presignedUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents($filePath));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');

$headers = a];
$headers$] = 'Content-Type: ' . $contentType;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
if (curl_errno($ch)) {
$this->logger->critical('Error on uploading file to Pipefy', icurl_error($ch)]);
// echo 'Error:' . curl_error($ch);
}
curl_close($ch);

$this->logger->info('Uploaded file', $presignedUrl, $filePath, $response]);
$attachmentValue = ltrim(parse_url($presignedUrl, PHP_URL_PATH), '/');

// Add to card field
$addToCardMutation = (new Mutation('updateCardField'))->setArguments(g'input' => new RawObject('{
card_id: "' . $cardId . '",
field_id: "' . $fieldId . '",
new_value: _"' . addslashes($attachmentValue) . '"]
}')])->setSelectionSet(t'success', 'clientMutationId']);

$addToCardResults = $this->runGraphQLQuery($addToCardMutation);
$attachmentQueryResults = null;

if ($addToCardResultsd'updateCardField']d'success']) {
$queryAttachmentURL = (new Query('card'))
->setArguments(g'id' => $cardId])
->setSelectionSet(t
(new Query('attachments'))->setSelectionSet(t
'url', 'path', (new Query('field'))->setSelectionSet(t'id', 'internal_id']),
]),
]);
$attachmentQueryResults = $this->runGraphQLQuery($queryAttachmentURL);
foreach ($attachmentQueryResultsy'card']['attachments'] as $key => $attachment) {
if (!$attachmentt'field']) {
$this->logger->warning('Attachment has no field', f$attachment]);
} else {
if ($attachmentt'field']''id'] == $fieldId) {
$this->logger->debug('Found attachment field', f$attachment]);

return $attachmentt'url'];
}
}
}
}
$this->logger->critical('Attachment not found after upload', p$addToCardResults, $attachmentQueryResults]);

return '';
}

 


Hi @avalizei, howa re you doing today?:slight_smile:
Could you check if the information in this link helps you, please? 

https://developers.pipefy.com/docs/how-to-upload-attachments-and-attach-to-a-card-record#sample-curl-commands

Let me know if you need anything else!:wink:


Hi @avalizei, howa re you doing today?:slight_smile:
Could you check if the information in this link helps you, please? 

https://developers.pipefy.com/docs/how-to-upload-attachments-and-attach-to-a-card-record#sample-curl-commands

Let me know if you need anything else!:wink:

 

Hi Lais! How are you? This is not working!

In the step that tells us to upload the file it gives us the code 200 and the file appears on the other card, but when I download it, it has 1kb and don’t opens.


Hi @avalizei, howa re you doing today?:slight_smile:
Could you check if the information in this link helps you, please? 

https://developers.pipefy.com/docs/how-to-upload-attachments-and-attach-to-a-card-record#sample-curl-commands

Let me know if you need anything else!:wink:

 

Hi Lais! How are you? This is not working!

In the step that tells us to upload the file it gives us the code 200 and the file appears on the other card, but when I download it, it has 1kb and don’t opens.

@lais-laudari can you please give us a extra help here? 


Hi @avalizei, howa re you doing today?:slight_smile:
Could you check if the information in this link helps you, please? 

https://developers.pipefy.com/docs/how-to-upload-attachments-and-attach-to-a-card-record#sample-curl-commands

Let me know if you need anything else!:wink:

 

Hi Lais! How are you? This is not working!

In the step that tells us to upload the file it gives us the code 200 and the file appears on the other card, but when I download it, it has 1kb and don’t opens.

@lais-laudari can you please give us a extra help here? 

Hi @lais-laudari and @Juliana Spinardi. I’ve managed to get it to work. I wasn’t sending the data to the upload step. The fact is that i’m using Integromat, a integrator web software. Anyway, its working now. Thanks for your reply.


Hello @tobiasbaco 

I see you decided the same problem using integromat.
Can you help me? How do you create step 2 from this documentation using Integromat?
I can’t understand how to create it.

Thanks


Hello @tobiasbaco 

I see you decided the same problem using integromat.
Can you help me? How do you create step 2 from this documentation using Integromat?
I can’t understand how to create it.

Thanks

Hi Kal! How are you? Here it is the modules. Just follow the doc ahead, of course using your variables. If need any help please contact me.

 


Hello @tobiasbaco 

I see you decided the same problem using integromat.
Can you help me? How do you create step 2 from this documentation using Integromat?
I can’t understand how to create it.

Thanks

I found solution.
Sorry, for distrub.


Hello @tobiasbaco 

I see you decided the same problem using integromat.
Can you help me? How do you create step 2 from this documentation using Integromat?
I can’t understand how to create it.

Thanks

Hi Kal! How are you? Here it is the modules. Just follow the doc ahead, of course using your variables. If need any help please contact me.

 

@tobiasbaco  
Sorry, I don’t see you answer.
Thanks a lot.
Have a nice day.


Reply