@hussein depending on which programing language you’re using you can do option 1 but the process of saving the PDF to file field must be done in the code when you’re using /myowncustomAPI.
So what I’m thinking is:
- Create a pipe that sends data to /myowncustomAPI
- /myowncustomAPI generates the PDF and saves it locally on the server
- /myowncustomAPI then uploads the saved PDF to a file field in Tadabase
- /myowncustomAPI sends a JSON response with success message.
Uploading file from API is a bit tricky, but here’s a PHP snippet that might help.
This relies on having
composer require pear/http_request2
Then here’s the PHP code:
<?php
require 'vendor/autoload.php';
//require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://api.tadabase.io/api/v1/data-tables/K68j9gN2V7/records');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'X-Tadabase-App-id' => 'b1r***QKk',
'X-Tadabase-App-Key' => 'SpX*****QoiQ',
'X-Tadabase-App-Secret' => '3HLO***********WvERh0eLT'
));
$request->addUpload('field_70', 'My-Local-File-Location.pdf', 'filename.pdf', '<Content-Type Header>');
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}