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;
}
}
  • @return array|int|string|bool|float Scalar or array of scalars – Aditya Shah Jun 12 '18 at 5:58
  • Have you tried this ? – Aditya Shah Jun 12 '18 at 6:26
0

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 
  • This returns: Class mixed does not exist. and with string[] returns: Class string[] does not exist. This is a magento issue? – Douglas Ianitsky Oct 4 '18 at 12:17
  • No, please share your code. – Aditya Shah Oct 4 '18 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.