System: p74448.my.plentysystems.com
Goal: In a custom plugin I receive a shipping-label PDF over REST and want to attach it to an order as a downloadable document (order Documents section). I’m calling, inside an AuthHelper::processUnguarded context:
DocumentRepositoryContract::uploadOrderDocuments(int $orderId, string $type, array $data)
Problem: every $data structure I try throws a generic exception whose message is only "validation error found" with no field-level detail. The valid $type values are documented (invoiceExternal, deliveryNote, …), but the $data array structure is not documented anywhere I can find, the interface PHPDoc and docs-raw only say „Upload order documents.“
Structures I’ve tried (with $type = 'deliveryNote'), all returning "validation error found":
-
[ ['numberWithLeadingZeros' => (string)$orderId, 'documents' => [ ['base64' => $b64, 'fileName' => $fn] ]] ] -
same as (1) but
fileDatainstead ofbase64 -
same as (1) but
contentinstead ofbase64 -
[ ['base64' => $b64, 'fileName' => $fn] ](flat, no wrapper)
I also tried uploadOrderShippingPackageDocuments(int $packageId, string $type, string $document) with $type = 'shippingLabel' and $document = the base64 string, same "validation error found".
The content is a valid base64-encoded PDF (verified).
Could you provide:
-
The exact required
$dataarray structure foruploadOrderDocuments(field names + required keys) for a type likedeliveryNote(or a generic/external type suitable for an arbitrary uploaded PDF), ideally a minimal working PHP example. -
The request structure and valid
$typevalues foruploadOrderShippingPackageDocuments.
I can share the full plugin code on request.