2

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.

1 Answer 1

0

Unfortunately, as of this writing, there is no access to EntityFile in Api v4. This is the missing link between the Activity and File that you created. (In Api v3, you could add a file to an activity using Attachment.create, but that has not yet been ported to Api v4 either.)

I added a comment on this page, which tracks which entities are supported by Api v4.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.