get(\Magento\Sales\Model\ResourceModel\Order\Invoice\Collection::class); $invoice = $invoiceCollection->getFirstItem(); $commentData = [ InvoiceCommentInterface::COMMENT => 'Hello world!', InvoiceCommentInterface::ENTITY_ID => null, InvoiceCommentInterface::CREATED_AT => null, InvoiceCommentInterface::PARENT_ID => $invoice->getId(), InvoiceCommentInterface::IS_VISIBLE_ON_FRONT => 1, InvoiceCommentInterface::IS_CUSTOMER_NOTIFIED => 1, ]; $requestData = ['entity' => $commentData]; $serviceInfo = [ 'rest' => [ 'resourcePath' => '/V1/invoices/comments', 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, ], 'soap' => [ 'service' => self::SERVICE_READ_NAME, 'serviceVersion' => self::SERVICE_VERSION, 'operation' => self::SERVICE_READ_NAME . 'save', ], ]; $result = $this->_webApiCall($serviceInfo, $requestData); $this->assertNotEmpty($result); } }