0

I created web api and trying to validate entered data ":postcode".

Here is code in etc/webapi.xml

<?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/postcode/check/:postcode" method="GET"> <service class="Modules\ShippingMethod\Api\Data\PostcodeInterface" method="check"/> <resources> <resource ref="anonymous"/> </resources> </route> </routes> 

When I send

curl http://site.dev/rest/default/V1/postcode/check/0003 

the var_dump() inside "check" method gives me an integer value "3", but I need to get full variable with all zero symbols and, maybe, specify string type for it. How can I specify variable type or get full request variable?

1 Answer 1

0

Are you annotation for method Modules\ShippingMethod\Api\Data\PostcodeInterface::check($postcode) define $postcode as int? If yes, change it to string to resolve problem

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.