先确认问题层级

REST创建客户地址时标准字段正常,自定义字段却返回Custom attribute is invalid。先核对属性实体、输入代码和前后台表单配置。

确认属性创建在customer_address实体而不是customer实体,并检查attribute_code拼写与数据类型。

请求体按custom_attributes数组提交attribute_code/value;多选值按接口要求传字符串或数组,不能直接发送后台标签。

修复方法

  • 检查属性已加入正确Attribute Set/Group并允许用于相应表单;API写入还需Service Contract可见。
  • 清EAV和config缓存后用GET读回地址;若只在某Website失败,核对客户Website与地址归属。
GET /rest/V1/attributeMetadata/customerAddressPOST /rest/V1/customers/123/addressesSELECT attribute_id,attribute_code,backend_type FROM eav_attribute WHERE entity_type_id=(SELECT entity_type_id FROM eav_entity_type WHERE entity_type_code='customer_address');

怎样才算解决

同一地址可通过REST新增、修改和清空该属性,后台打开后值一致,非法选项返回明确错误。