I create activities using the API, and now I need to add an uploaded file (meaning it was uploaded in a Drupal form) to the activity. I tried this:
$results = \Civi\Api4\Activity::create()
->addValue('activity_type_id', 91)
->addValue('target_contact_id', [ 8, ])
->addValue('source_contact_id', 2)
->addValue('subject', 'test')
->addChain('uploaded_invoice',
\Civi\Api4\File::create()->addValue('mime_type', 'text/plain')
->addValue('document', 'Just Testing')
->addValue('description', 'Invoice Scan')
)
->execute();
But this doesn't work, it creates the Activity, but no file is attached.