cancel
Showing results for 
Search instead for 
Did you mean: 

How to get customer details by telephone Number Magento2 rest Api?

How to get customer details by telephone Number Magento2 rest Api?

 
I have used this end point get request <yoursite.com>/rest/<store_code>/V1/customers/search with the following parameters:
searchCriteria[filterGroups][0][filters][0][field]: addresses[telephone]searchCriteria[filterGroups][0][filters][0][value] : 123456789searchCriteria[filterGroups][0][filters][0][conditionType]: eq

But still not able to get the desire result only error occur as the addresses[telephone] does not field any magento2 rest API expert here.

7 REPLIES 7

Re: How to get customer details by telephone Number Magento2 rest Api?

Hi @devcx9gmai328a 


Try below search query:

searchCriteria[filterGroups][0][filters][0][field]: telephone&
searchCriteria[filterGroups][0][filters][0][value] : 123456789&
searchCriteria[filterGroups][0][filters][0][conditionType]: eq

Also check with you system. Field name is "telephone" or "phone". Change according to field name.

Problem Solved? Please click on 'Kudos' & Accept as Solution!

Problem solved? Click Accept as Solution!

Re: How to get customer details by telephone Number Magento2 rest Api?

Hi @devcx9gmai328a ,

 

According to Vanilla Magento's structure, there is no Customer attribute as Telephone. We have a telephone as a Customer address attribute. This may be the reason behind the issue in the search using Rest API.

 

For Making customer search using Telephone you need to perform the below steps:

1. You need to create a custom attribute like a phone/telephone for the customer entity.

2.  Saving the data in this attribute and enable it for 'Use in Search'.

 

Hope this helps you!

Problem Solved! Click Kudos & Accept as Solution!

Re: How to get customer details by telephone Number Magento2 rest Api?

Thanks for the reply I have tried this solution but getting an error that there is no attribute of telephone in customer. As per metadata of customer telephone exists inside the addresses array so how can I able to search customer via telephone using REST-API ? will wait for you response. 

{
  "id": 0,
  "group_id": 0,
  "default_billing": "string",
  "default_shipping": "string",
  "confirmation": "string",
  "created_at": "string",
  "updated_at": "string",
  "created_in": "string",
  "dob": "string",
  "email": "string",
  "firstname": "string",
  "lastname": "string",
  "middlename": "string",
  "prefix": "string",
  "suffix": "string",
  "gender": 0,
  "store_id": 0,
  "taxvat": "string",
  "website_id": 0,
  "addresses": [
    {
      "id": 0,
      "customer_id": 0,
      "region": {
        "region_code": "string",
        "region": "string",
        "region_id": 0,
        "extension_attributes": {}
      },
      "region_id": 0,
      "country_id": "string",
      "street": [
        "string"
      ],
      "company": "string",
      "telephone": "string",
      "fax": "string",
      "postcode": "string",
      "city": "string",
      "firstname": "string",
      "lastname": "string",
      "middlename": "string",
      "prefix": "string",
      "suffix": "string",
      "vat_id": "string",
      "default_shipping": true,
      "default_billing": true,
      "extension_attributes": {},
      "custom_attributes": [
        {
          "attribute_code": "string",
          "value": "string"
        }
      ]
    }
  ]

Re: How to get customer details by telephone Number Magento2 rest Api?

I am developing Magento integration and I don't have direct access to Magento2 only rest-API to perform crud operation basis on the provided data so what should be filtered look like to search nested object data using rest- services as I directly access customer via email but I need to search the customer based on the telephone. Thanks for the reply will wait for your response. 

{
  "id": 0,
  "group_id": 0,
  "default_billing": "string",
  "default_shipping": "string",
  "confirmation": "string",
  "created_at": "string",
  "updated_at": "string",
  "created_in": "string",
  "dob": "string",
  "email": "string",
  "firstname": "string",
  "lastname": "string",
  "middlename": "string",
  "prefix": "string",
  "suffix": "string",
  "gender": 0,
  "store_id": 0,
  "taxvat": "string",
  "website_id": 0,
  "addresses": [
    {
      "id": 0,
      "customer_id": 0,
      "region": {
        "region_code": "string",
        "region": "string",
        "region_id": 0,
        "extension_attributes": {}
      },
      "region_id": 0,
      "country_id": "string",
      "street": [
        "string"
      ],
      "company": "string",
      "telephone": "string",
      "fax": "string",
      "postcode": "string",
      "city": "string",
      "firstname": "string",
      "lastname": "string",
      "middlename": "string",
      "prefix": "string",
      "suffix": "string",
      "vat_id": "string",
      "default_shipping": true,
      "default_billing": true,
      "extension_attributes": {},
      "custom_attributes": [
        {
          "attribute_code": "string",
          "value": "string"
        }
      ]
    }
  ]  

 

Re: How to get customer details by telephone Number Magento2 rest Api?

Did you eventually find a solution? I am struggling with the same problem.

Re: How to get customer details by telephone Number Magento2 rest Api?

Did you eventually find a solution? I am struggling with the same problem.

Re: How to get customer details by telephone Number Magento2 rest Api?

I am working on a Magento integration where I have access only to the Magento 2 REST API for performing CRUD operations. I need guidance on how to filter and search nested object data using the REST services. Currently, I can directly access customer information using their email, but I also need to search for customers based on their telephone numbers. Thank you for your response, and I look forward to hearing from you.