2

I've been trying to use SharePoint REST API to retrieve a number of files on my site but for some reason, if it does tell me the name or descriptions of the files, it returns null for every single custom columns I have for those files.

Here's the code I use:

const path = "Path:" + AppState.context.pageContext.web.absoluteUrl + "/* ";
const url = AppState.context.pageContext.web.absoluteUrl + "/_api/search/query?querytext='" + path + "IsDocument:true'&selectproperties='Status,Title,Path,Created,Description,MGS_Hierarchy'";

and here are the example of a result:

Results of the query

As you can see, the "Status" and "MGS_Hierarchy" values are null, even tough they are set in the list:

enter image description here

The two columns are inherited from a custom content type. I don't know if it changes something.

Any help is greatly appreciated.

1
  • Just confirming. Are those custom site columns added to document library? Are you using correct managed property names for columns? Apr 6, 2022 at 9:48

1 Answer 1

0

You have to use the managed property names for the custom columns to retrieve custom column values using SharePoint Search REST API.

Make sure you are using correct managed property names for the custom columns.

You can find the managed property names from Search Schema in site settings.

Follow below links for more information:

  1. How to Identify Custom Property Names in SharePoint
  2. SharePoint Search REST API overview
1
  • This doesn't tell a person how to solve the issue. Sep 14 at 21:23

Your Answer

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

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