I’m trying to add a file to a deal in PHP using Pipedrive’s composer package v12.0.2, but it keeps failing with a 400 http code with message: {"success":false,"error":"An error occurred while saving the file.","error_info":"Ga naar developers.pipedrive.com voor meer informatie over Pipedrive API.","data":{"error_code":"unknown_error"},"additional_data":null}
I checked the docs but I don’t see what’s wrong. This exact code used to work last year:
$pdConfig = (new Configuration())->setApiKey('x-api-token', env('PIPEDRIVE_TOKEN'));
$organizationApi = new \Pipedrive\versions\v1\Api\OrganizationsApi(config: $pdConfig);
$organization = $organizationApi->addOrganization([
'name' => $company,
'address' => $address,
]);
$dealApi = new \Pipedrive\versions\v1\Api\DealsApi(config: $pdConfig);
$deal = $dealApi->addDeal([
'title' => $title,
'org_id' => $organization['data']['id'],
]);
$fileApi = new \Pipedrive\versions\v1\Api\FilesApi(config: $pdConfig);
$file = $fileApi->addFile(
new SplFileObject($_FILES['file']['tmp_name']),
$deal['data']['id'],
);
Adding a deal and organization does work, but it fails when adding a file. The files do upload correctly.