1

Property "Mobilenumber" does not have accessor method "getMobilenumber" in class "Magento\Customer\Api\Data\CustomerInterface".

Whenever i am trying to set customer custom attribute value i am getting above error. does anyone know how to save customer custom attribute value using REST API ?

0

1 Answer 1

1

i got the answer, you should have to use below code to update customer custom attribute

$customAttributeValues=array("attributeCode" => "mobilenumber", "value" => "918985552230");

$customerData = [
    'customer' => [
        'id' => 5,
        "email" => "[email protected]",
        "firstname" => "Magecomp",
        "lastname" => "Tester",
        "storeId" => 1,
        "websiteId" => 1,
        "customAttributes" => [$customAttributeValues],
    ]
];

$ch = curl_init("http://127.0.0.1/m232/rest/V1/customers/5");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($customerData));
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: Bearer " . json_decode($token)));

$result = curl_exec($ch);

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.