1

Using magento 2.2. I create rest api for edit address which need pass param in 'array of string' but i get an error:

Doc: Magento Configure services as web APIs

Used array of string for pass param

"street": ["new, wat phnom, phnom penh"]

Message

"message": "Error occurred during \"street\" processing. Invalid type for value: \"array\". Expected Type: \"string\".",

My JSON

{ "address":{ "addressId":85, "street": ["new, wat phnom, phnom penh"], "latitude":"11.33333664", "longitude":"104.99778855" } }

Interface

<?php
namespace Iota\EShopping\Model\Address;

class Address
 {
private $addressId;
private $street;


/**
 * addressId
 * @return int
 */
public function getAddressId(){
    return $this->addressId;
}

/**
 * addressId
 * @param int $addressId
 * @return Address
 */
public function setAddressId($addressId){
    $this->addressId = $addressId;
    return $this;
}


/**
 * street
 * @return string
 */
public function getStreet(){
    return $this->street;
}

/**
 * street
 * @param string[] $street
 * @return Address
 */
public function setStreet($street){
    $this->street = $street;
    return $this;
}
}
2
  • @return array|int|string|bool|float Scalar or array of scalars Commented Jun 12, 2018 at 5:58
  • Have you tried this ? Commented Jun 12, 2018 at 6:26

1 Answer 1

1

Valid scalar types include: mixed (or anyType), bool (or boolean), str (or string), integer (or int), float, and double

Any parameters or return values of type array can be denoted by following any of the previous types by an empty set of square brackets []

@return array|int|string|bool|float Scalar or array of scalars 
2
  • This returns: Class mixed does not exist. and with string[] returns: Class string[] does not exist. This is a magento issue? Commented Oct 4, 2018 at 12:17
  • No, please share your code. Commented Oct 4, 2018 at 12:22

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.