I am facing one issue while adding new address of a existing customer using its id. I am explaining my code below.

$ch = curl_init();
$data = array("username" => "raj", "password" => "raj@0987.");

$data_string = json_encode($data);                       
$ch = curl_init($adminUrl); 
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                                                                  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
    'Content-Type: application/json',                                                                                
    'Content-Length: ' . strlen($data_string))                                                                       
$token = curl_exec($ch);
//echo $user_id;exit;
$sql=mysqli_query($conn,"select * from mobusers where id='".$user_id."'");
    $ent_id=$row['entity_id'];//customer's id
    $customerData = [
        'customer' => [
            'addresses' => [
                    "firstname"=> $first_name,
                    "lastname"=> $last_name,
                    "company"=> $company,
                    "street"=> [
                    "city"=> $city,
                    "postcode"=> $pin,
                    "country_id"=> $country_id,
                    "telephone"=> $mobile
    //echo $requestUrl;exit;
    $ch = curl_init();
    $ch = curl_init($requestUrl); 
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    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); 

    $result = json_decode($result, 1);
    if(!isset($result['message']) && $result > 0){
        $response['msg']="Your addresse has been updated successfully.";
    echo json_encode($response);

Here I have already one existing customer and while registered he does not add any address. I have already the customer's id(i.e-$ent_id(entity_id of customer entity table)) which will be the parent ID of the address table. Using this ID I want to add this new address to address table. But in my case I am getting the following error.

    [message] => Request does not match any route.
    [trace] => 

Here I need to add this address using this customer id.Please help me.

  • In Customer module this by this url of api is used for PUT method can you change your method from POST to PUT and then try once. Aug 27, 2018 at 6:41
  • @CharulTyagi : I have already applied PUT method but its not updating anything.
    – satya
    Aug 27, 2018 at 6:45


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.