Required $data structure for DocumentRepositoryContract::uploadOrderDocuments

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":

  1. [ ['numberWithLeadingZeros' => (string)$orderId, 'documents' => [ ['base64' => $b64, 'fileName' => $fn] ]] ]

  2. same as (1) but fileData instead of base64

  3. same as (1) but content instead of base64

  4. [ ['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:

  1. The exact required $data array structure for uploadOrderDocuments (field names + required keys) for a type like deliveryNote (or a generic/external type suitable for an arbitrary uploaded PDF), ideally a minimal working PHP example.

  2. The request structure and valid $type values for uploadOrderShippingPackageDocuments.

I can share the full plugin code on request.

Try this

$data = [
    'documents' => [
        [
            'content' => base64_encode($fileContent),
            'numberWithPrefix' => '100'
        ]
    ]
];

but without a guarantee, the solution is from the old forum from 2017