I am getting the following error while updating the record using the Magento 2 REST API.
Error:
( [message] => Request does not match any route. [trace] => )
I am explaining my code below.
$customerData = [
'customer' => [
"id" => 25,
"email" => "[email protected]",
"firstname" => "subhrajy",
"lastname" => "pradhan",
"storeId" => 1,
"websiteId" => 1,
"customAttributes" => [
],
"addresses" => [
]
],
"password" => "subhra123@"
];
$headers = array("Authorization: Bearer $token");
$requestUrl='http://hostapp.com/index.php/rest/V1/customers/25';
$ch = curl_init();
$ch = curl_init($requestUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
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 " . $token));
$result = curl_exec($ch);
$result = json_decode($result, 1);
echo '<pre>';print_r($result);
Here I trying to update only the password using entity_id
and getting the above error. I am using the postman and setting the PUT
method there. Here I need to update those data for a customer.