SharePoint Webservice clientPeoplePickerSearchUser

Problem

 
In one of our projects we were using SharePoint client People picker web service to fetch all users and groups to populate a people picker field in SPFx, below is the web service we used. The web service accepts query parameters as shown below and suddenly stopped working in the first two weeks of Apr 2021.
 
~site/_api/SP.UI.ApplicationPages.ClientPeoplePickerWebServiceInterface.clientPeoplePickerSearchUser
 
Actual code 
  1. const userRequestUrl = `${this.props.siteUrl}/_api/SP.UI.ApplicationPages.ClientPeoplePickerWebServiceInterface.clientPeoplePickerSearchUser`;  
  2. const userQueryParams = {  
  3.     'queryParams': {  
  4.         'AllowEmailAddresses'true,  
  5.         'AllowMultipleEntities'false,  
  6.         'AllUrlZones'false,  
  7.         'MaximumEntitySuggestions': 15,  
  8.         'QueryString': terms  
  9.     }  
  10. };  
  11. return this.props.spHttpClient.post(userRequestUrl, SPHttpClient.configurations.v1, {  
  12.     body: JSON.stringify(userQueryParams)  
  13. }).then((httpResponse: SPHttpClientResponse) => {  
  14.     return httpResponse.json();  
  15. })   
There were no (empty array) results when we pass any search terms.
 

Solution

 
Upon research we found that there was a recent change by Microsoft which made this combination of parameters to this API not work. We had to change the query parameters to include principle source and principle type. Folllowing is the updated query paramters which we used with the same API and it started working.
  1. const userQueryParams = {  
  2.         'queryParams': {  
  3.             'AllowEmailAddresses'true,  
  4.             'AllowMultipleEntities'false,  
  5.             'AllUrlZones'false,  
  6.             'MaximumEntitySuggestions': 15,  
  7.             'QueryString': terms,  
  8.             'PrincipalSource': 15,  
  9.             'PrincipalType': 13  
  10.         }   
Code after changes,
  1. const userRequestUrl = `${this.props.siteUrl}/_api/SP.UI.ApplicationPages.ClientPeoplePickerWebServiceInterface.clientPeoplePickerSearchUser`;  
  2. const userQueryParams = {  
  3.     'queryParams': {  
  4.         'AllowEmailAddresses'true,  
  5.         'AllowMultipleEntities'false,  
  6.         'AllUrlZones'false,  
  7.         'MaximumEntitySuggestions': 15,  
  8.         'QueryString': terms,  
  9.         'PrincipalSource': 15,  
  10.         'PrincipalType': 13  
  11.     }  
  12. };  
  13. return this.props.spHttpClient.post(userRequestUrl, SPHttpClient.configurations.v1, {  
  14.         body: JSON.stringify(userQueryParams)  
  15.     }).then((httpResponse: SPHttpClientResponse) => {  
  16.             return httpResponse.json();  
  17.         }  
There are no documentations found on this issue and hence I'm writing my first one!