cancel
Showing results for 
Search instead for 
Did you mean: 

REST API multiselect attribute values are sent in an incompatible format and cannot be cleared

0 Kudos

REST API multiselect attribute values are sent in an incompatible format and cannot be cleared

Feature request from dnadle, posted on GitHub Aug 11, 2016

Preconditions

  1. Magento 2.1.0

Steps to reproduce

  1. Add a product attribute with multiple select input type and define several options (values).
  2. Choose a sku set some values for the attribute.
  3. GET the sku with /V1/products/{sku}
  4. Wrap the returned JSON body with { "product": <JSON GET result> }.
  5. PUT the sku with /V1/products/{sku}
  6. Edit the JSON body and set the attribute value to [] (empty array).
  7. PUT the sku again.

Expected result

  1. The unchanged results of a GET should PUT without errors.
  2. A multi select attribute with a single option with id "123" selected should be sent as ["123"].
  3. Multiple options selected should look like ["123","456"].
  4. Putting a an empty array should clear all the selected options for the attribute.

Actual result

  1. Putting an unchanged GET returns errors on the multiselect attribute: { "message": "Error occurred during \"custom_attributes\" processing. Attribute \"occasion\" has invalid value. Invalid type for value: \"string\". Expected Type: \"string[]\"." }
  2. If the attribute has a single option, it is sent as "123", not ["123"].
  3. If the attribute has multiple options, it is sent as "123,456", not ["123","456"].
  4. Putting an empty array does not remove whatever options are selected.
5 Comments
apiuser
New Member

Comment from sevos1984, posted on GitHub Sep 06, 2016

After 7th step I get updated product, if I send values:[] I get "Invalid option value" message. Only 4th point of expected is reproduced and it looks like improvement.

apiuser
New Member

Comment from dnadle, posted on GitHub Sep 06, 2016

I don't understand this comment. All four points of "expected" are what should happen. If any one of those points do not happen it is clearly a bug.

apiuser
New Member

Comment from dnadle, posted on GitHub Sep 06, 2016

In 2.1.1, Above actual results 1 though 4 still happen. This is still a bug and the tag should not have been removed.

apiuser
New Member

Comment from pboisvert, posted on GitHub Sep 06, 2016

@mbrinton01 please review this one and confirm if bug or improvement

dnadle
Occasional Contributor

 This is not a feature request or improvement, it's a bug. Actually, it's several bugs. I wish someone at Magento would actually read the report and understand what it means before dismissing it.