I made an API which returns wishlist of a user using customer_token as authentication, obtained via this API:


My webapi.xml looks something like:

        <?xml version="1.0"?>
    <routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
     <route url="/V1/fetch_wishlist/" method="GET">
            <service class="Vendor\WishlistApi\Api\WishlistInterface" method="setData"/>
                <resource ref="self" />
                <parameter name="customerId" force="true">%customer_id%</parameter>

But I am getting an error as:

"message": "Invalid type for value: \"string\". Expected Type: \"string[]\".",
"trace": null

Rest of my code is correct, I used this API with anonymous resource in webapi.xml and it works fine if i send the payload as:

{"customerId": [3500]}

However I get the same exact error if I put the payload as:

{"customerId": 3500}

Any suggestions?

2 Answers 2


Fixed it by including these comments over the function in the interface:

 * GET for wishlist api
 * @param string $customerId
 * @return string
  • param string $customerId this should be param int $customerId. When you pass token in header it converts to customer id which is type of integer value Commented Jun 7, 2019 at 5:05

I wish complement previous response, additionally, change type in @param, you need compile the project, so its works

good luck !


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.