getParsedBody(); $id = $data->id ?? null; $field = $data->field ?? null; $parentType = $data->parentType ?? null; $relatedType = $data->relatedType ?? null; if (!$id || !$field) { throw new BadRequest("No `id` or `field`."); } try { $fieldData = new FieldData( $field, $parentType, $relatedType ); } catch (Error $e) { throw new BadRequest($e->getMessage()); } $attachment = $this->getDocumentService()->copyAttachment($id, $fieldData); return [$attachment->getValueMap()]; } private function getDocumentService(): Service { return $this->injectableFactory->create(Service::class); } }