Skip to main content
Updated answer as per request
Source Link
Vishwas Bhatnagar
  • 4.7k
  • 3
  • 38
  • 61
<route url="/V1/ipwishlistreview/items"mine/post" method="GET">method="POST">
    <service class="Ipragmatech\Ipreview\Api\ReviewInterface" method="writeReviews"/>
   <service class="Creaticity\Ipwishlist\Api\WishlistManagementInterface"<resources>
 method="getWishlistForCustomer"       <resource ref="self" />
    </resources>
    <resources><data>
        <parameter name="customer_id" force="true">%customer_id%</parameter>
  <resource ref="self" </>data>
</route>

And API signature in \Ipreview\Api\ReviewInterface

 /**
     * Added </resources>review and rating for the product.
     * @param int <data>$productId
     * @param string $title
    <parameter name="customerId"* force="true">%customer_id%</parameter>@param string $nickname
     * @param string </data>$detail
    < * @param Ipragmatech\Ipreview\Api\Data\RatingInterface[] $ratingData
     * @param int $customer_id
     * @param int $store_id
     * @return boolean
     *
     */route>
    public function writeReviews(
        $productId,
        $nickname,
        $title,
        $detail,
        $ratingData,
        $customer_id = null,
        $storeId
    );

So whenever you are setting ref as self the data will be taken from the token passed as bearer token and data node below it specify which data has to be taken form the the token . In above case it is customer ID , it also can be token .

So to answer your question you just have to pass token of logged-in user and it $customer_id will fetch the customer idbe taken from token and rest of the params can be passed in below body format

{
            "productId": "10",
            "nickname": "Mann",
            "title": "Cool, Nice product",
            "detail": "This is nice product. I recommended this product.",
            "ratingData": [{
                "rating_id": "3",
                "ratingCode": "price",
                "ratingValue": "5"
            }, {
                "rating_id": "4",
                "ratingCode": "Rating",
                "ratingValue": "2"
            }],
            "storeId": "1"
         }
<route url="/V1/ipwishlist/items" method="GET">
        <service class="Creaticity\Ipwishlist\Api\WishlistManagementInterface" method="getWishlistForCustomer"/>
        <resources>
            <resource ref="self" />
        </resources>
        <data>
            <parameter name="customerId" force="true">%customer_id%</parameter>
        </data>
    </route>

So whenever you are setting ref as self the data will be taken from the token passed as bearer token and data node below it specify which data has to be taken form the the token . In above case it is customer ID , it also can be token .

So to answer your question you just have to pass token of logged-in user and it will fetch the customer id from token

<route url="/V1/review/mine/post" method="POST">
    <service class="Ipragmatech\Ipreview\Api\ReviewInterface" method="writeReviews"/>
    <resources>
        <resource ref="self" />
    </resources>
    <data>
        <parameter name="customer_id" force="true">%customer_id%</parameter>
    </data>
</route>

And API signature in \Ipreview\Api\ReviewInterface

 /**
     * Added review and rating for the product.
     * @param int $productId
     * @param string $title
     * @param string $nickname
     * @param string $detail
     * @param Ipragmatech\Ipreview\Api\Data\RatingInterface[] $ratingData
     * @param int $customer_id
     * @param int $store_id
     * @return boolean
     *
     */
    public function writeReviews(
        $productId,
        $nickname,
        $title,
        $detail,
        $ratingData,
        $customer_id = null,
        $storeId
    );

So whenever you are setting ref as self the data will be taken from the token passed as bearer token and data node below it specify which data has to be taken form the the token . In above case it is customer ID , it also can be token . $customer_id will be taken from token and rest of the params can be passed in below body format

{
            "productId": "10",
            "nickname": "Mann",
            "title": "Cool, Nice product",
            "detail": "This is nice product. I recommended this product.",
            "ratingData": [{
                "rating_id": "3",
                "ratingCode": "price",
                "ratingValue": "5"
            }, {
                "rating_id": "4",
                "ratingCode": "Rating",
                "ratingValue": "2"
            }],
            "storeId": "1"
         }
Source Link
Vishwas Bhatnagar
  • 4.7k
  • 3
  • 38
  • 61

If you inspect the module code etc/webapi.xml you will see following code

<route url="/V1/ipwishlist/items" method="GET">
        <service class="Creaticity\Ipwishlist\Api\WishlistManagementInterface" method="getWishlistForCustomer"/>
        <resources>
            <resource ref="self" />
        </resources>
        <data>
            <parameter name="customerId" force="true">%customer_id%</parameter>
        </data>
    </route>

So whenever you are setting ref as self the data will be taken from the token passed as bearer token and data node below it specify which data has to be taken form the the token . In above case it is customer ID , it also can be token .

So to answer your question you just have to pass token of logged-in user and it will fetch the customer id from token