I am trying to get all the users from the local people directory and display it. If I type this in the browser, I see all the data I need. If I use this in my code and compile it in spfx it does not work. may I know what is the fix ?

My search query

  • The code
private  getUser(){
 var qurl;

   const opt: ISPHttpClientOptions = { headers: {
      'Content-Type': 'application/json;odata=verbose'
   this.props.SPHttpClient.get(this.props.pagecontext.web.absoluteUrl + qurl, SPHttpClient.configurations.v1,opt)
   .then((response: SPHttpClientResponse) => { debugger;
       response.json().then((json: any) => { debugger;
        for(let i=0;i<json.value.length;i++){debugger; // json.value cannot read property , .value undefined


// codes continue...

I found that its a query so i must use

this.props.spHttpClient.get(url, SPHttpClient.configurations.v1, opt).then(response=>{

                let result = res.PrimaryQueryResult.RelevantResults.Table.Rows;

I can get

0: {Key: "RowLimit", Value: "60", ValueType: "Edm.Int32"}
1: {Key: "SourceId", Value: "b09a7990-05ea-4af9-81ef-edfab16c4e31", ValueType: "Edm.Guid"}
2: {Key: "CorrelationId", Value: "e9c7339f-e0fd-b000-e515-bff3355a8995", ValueType: "Edm.Guid"}
3: {Key: "EnableInterleaving", Value: "true", ValueType: "Edm.Boolean"}
4: {Key: "IsMissingUnifiedGroups", Value: "false", ValueType: "Edm.Boolean"}
5: {Key: "Constellation", Value: "i4302D", ValueType: "Edm.String"}
6: {Key: "MultiGeoSearchStatus", Value: "Full", ValueType: "Edm.String"}
7: {Key: "IsPartial", Value: "false", ValueType: "Edm.Boolean"}
8: {Key: "InternalRequestId", Value: "fa2dfdc9-e705-40e3-a99e-468cedbe7d4a", ValueType: "Edm.String"}
9: {Key: "SerializedQuery", Value: "<Query Culture="en-US" EnableStemming="True" Enabl…070cd" KeywordType="True" HiddenConstraints="" />", ValueType: "Edm.String"}
length: 10

but it no primary data result. if I append the link it shows in the browser What is the solution?


Using V3 ODATAVERSION SAME RESULTS. enter image description here


Can you please try change the OData version on rest api call.the Search REST API doesn't accept OData v4. Example:

let config: SPHttpClientConfiguration = new SPHttpClientConfiguration({
    defaultODataVersion: ODataVersion.v3

this.props.context.spHttpClient.get(this.props.context.pageContext.web.absoluteUrl + searchUrl, config, { headers: { Accept: "application/json;odata=minimalmetadata;charset=utf-8" } }).then((response) => {
  • thanks shahul, but no luck same results. Nothing in PrimaryResults – Random I.T Feb 10 '20 at 13:14
  • 1) Your "querytext" seems empty "/_api/search/query?querytext='*'&sourceid='B09A7990-05EA-4AF9-81EF-EDFAB16C4E31'&rowlimit=60", Can you please update the rest endpioint from above and try – Shahul Hameed Feb 10 '20 at 16:10
  • oh .............. thanks so much. It finally worked.. may I know how did you which documents says REST API don't accept v4? – Random I.T Feb 10 '20 at 17:55
  • @RandomI.T - this is the github issue that says Search Rest API does not support OData v4(github.com/SharePoint/sp-dev-docs/issues/…) – Shahul Hameed Feb 11 '20 at 10:34
  1. Change ODataVersion to 3
  2. for querytext use * for selct all/ wildcard
const opt: ISPHttpClientOptions = { headers: {
  Accept: "application/json;odata=minimalmetadata;charset=utf-8"
 let config: SPHttpClientConfiguration = new SPHttpClientConfiguration({
  defaultODataVersion: ODataVersion.v3
this.props.SPHttpClient.get(this.props.pagecontext.web.absoluteUrl + qurl,config ,opt).then((response) => {
    response.json().then(res => { debugger;
      let result=res.PrimaryQueryResult.RelevantResults.Table.Rows.Cells;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.