Get custom list columns from Microsoft Search API

captain_atharv 511 Reputation points
2022-11-16T11:23:14.02+00:00

Hi,
I have a list which has a custom column named Issue. I'm using Microsoft Search API (https://learn.microsoft.com/en-us/graph/api/search-query?view=graph-rest-1.0) to search list items and I would like to get the value of this custom column for list items.
I have tried below queries but it is not returning the column
{
"requests": [
{
"entityTypes": [
"listItem"
],
"query": {
"queryString": "fix favorite"
},
"fields":[
"Issue"
]
}
]
}

{
"requests": [
{
"entityTypes": [
"listItem"
],
"query": {
"queryString": "fix favorite"
},
"fields":[
"label_Issue"
]
}
]
}

Can someone help me with this?

Microsoft 365 and Office SharePoint Development
Microsoft 365 and Office SharePoint For business Windows
Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. Srinivasa Rao Darna 6,761 Reputation points Microsoft External Staff
    2022-11-17T08:55:11.463+00:00

    Hi @captain_atharv ,

    Refer to specify select properties, with below sample snippet. I am able to get Title, WebUrl, Description properties which are requested in the Graph API.

    POST https://graph.microsoft.com/v1.0/search/query  
    {  
        "requests": [  
            {  
                "entityTypes": [  
                    "listItem"  
                ],  
                "query": {  
                    "queryString": "Issue 1"  
                },  
                "fields": [  
                    "id",  
                    "contentclass",  
                    "title",  
                    "webUrl",  
                    "Description"  
                ]  
            }  
        ]  
    }  
    

    Here is my search result screenshot.
    261364-spo-search-fields.png

    Fields that you are using fields should be from the crawled-and-managed-properties-overview.
    Since Title, Description are already mapped as managed properties, I am able to fetch using Graph response.

    If need to fetch any custom field which is not predefined crawled property, you need to add it to search schema, manage-search-schema.

    Hope this helps.
    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. HarmeetSingh7172 4,826 Reputation points
    2022-11-16T22:12:50.617+00:00

    Hello @captain_atharv

    Thanks for reaching out!

    I was able to reproduce this behavior. Initially, I was getting no data in Search Graph API response. However, I noticed that it took around 15 minutes to reflect the expected data in API response. Please refer below screenshots with request payload for better understanding.

    Sample request payload:

    {  
        "requests": [  
            {  
                "entityTypes": [  
                    "listItem"  
                ],  
                "query": {  
                    "queryString": "SSE"  
                },  
                "fields": [  
                    "Designation"  
                ]  
            }  
        ]  
    }  
    

    SharePoint List-

    261153-search10.png

    Graph API response-

    261083-search20.png

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.