Url : http://127.0.0.1/jodhpur/rest/V1/customers/731
body
{
"customer": {
"email": "abcd12@gmail.com",
"firstname": "Abc",
"lastname": "Xyz" ,
"custom_attributes": [
{
"attribute_code": "twilio_image",
"value": {
"base64EncodedData": "iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAWtJREFUeNpi/P//P8NgBkwMgxyMOnDUgTDAyMhIDNYF4vNA/B+IDwCxHLoakgEoFxODiQRXQUYi4e3k2gfDjMRajsP3zED8F8pmA+JvUDEYeArEMugOpFcanA/Ef6A0CPwC4uNoag5SnAjJjGI2tKhkg4rLAfFGIH4IxEuBWIjSKKYkDfZCHddLiwChVhokK8YGohwEZYy3aBmEKmDEhOCgreomo+VmZHxsMEQxIc2MAx3FO/DI3RxMmQTZkI9ALDCaSUYdOOrAIeRAPzQ+PxCHUM2FFDb5paGNBPRa5C20bUhxc4sSB4JaLnvxVHWHsbVu6OnACjyOg+HqgXKgGRD/JMKBoD6LDb0dyAPE94hwHAw/hGYcujlwEQmOg+EV9HJgLBmOg+FMWjsQVKR8psCBoDSrQqoDSSmoG6Hpj1wA6ju30LI9+BBX4UsC+Ai0T4BWVd1EIL5PgeO+APECmoXgaGtm1IE0AgABBgAJAICuV8dAUAAAAABJRU5ErkJggg==",
"type": "image/png",
"name": "new_image.png"
}
}
]
Response show
{
"message": "Error occurred during \"custom_attributes\" processing. Attribute \"twilio_image\" has invalid value. Invalid type for value: \"array\". Expected Type: \"string\".",
"trace": null
}
Please help how to solve this problem
Hi @desktop1
Seems like you're trying to add an image but the custom attribute you created accepts string, please follow the below method to add an image attribute of customer :
https://meetanshi.com/blog/create-custom-image-attribute-for-customer-in-magento-2/
I used this link https://meetanshi.com/blog/create-custom-image-attribute-for-customer-in-magento-2/ but getting same issue
"Error occurred during \"custom_attributes\" processing. Attribute \"customer_image\" has invalid value. Invalid type for value: \"array\". Expected Type: \"string\
Please help
Please share at which step you're getting this error. As I can see it is still expecting a string, Direct changing in InstallData.php will not show any change, you have to change version of InstallData.php to implement the new changes of file and then run :
php bin/magento setup:upgrade
I created new module using this link https://meetanshi.com/blog/create-custom-image-attribute-for-customer-in-magento-2/
I want to update customer image using rest api. Magento api supported image base in 64encoded formate.
How to update image using this api
Url: http://127.0.0.1/jodhpur/rest/V1/customers/731
Please help