Create Custom Rest Api in Magento2 and solution for "InvalidArgumentException" error

The interface must have proper dock blocks with the existing types. But your code doesn't have a return type. For example:

<?php 
/**
 * Product type provider
 *
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\Catalog\Api;

/**
 * @api
 */
interface ProductTypeListInterface
{
    /**
     * Retrieve available product types
     *
     * @return \Magento\Catalog\Api\Data\ProductTypeInterface[]
     */
    public function getProductTypes();

    /**
     * Retrieve available tests
     *
     * @return \Vendor\Module\Api\Data\TestInterface[]
     */
    public function getTests();
}

@Kandy

i used below code it working fine for me important is dont ignore the comments which is consider as param

<?php


namespace AlanKent\CalculatorWebService\Api;

use AlanKent\CalculatorWebService\Api\Data\PointInterface;

interface CalculatorInterface
{
    /**
     * Return the sum of the two numbers.
     *
     * @api
     * @param int $num1
     * @param int $num2
     * @return
     */
    public function add($num1, $num2);
}

Tags:

Rest

Api

Magento2