Link to home
Start Free TrialLog in
Avatar of Rog D
Rog DFlag for United States of America

asked on

Sharepoint Search API Call (QueryEX) Need to get a readable ContentType in my result set.

This code currently works but I would like to add some columns to the result set. Once such column is the ContentType of the document in the path column.

Here is the code I am using and it does indeed return a datatable with results but it has ContentTypeID (Some Unique Identifier).

SharePointSearchAPI.QueryService queryService = new SharePointSearchAPI.QueryService(); queryService.Url = SharePointServiceURL;

            queryService.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

            // set search string
            StringBuilder xmlString = new StringBuilder("<QueryPacket xmlns='urn:Microsoft.Search.Query'>" +
                            "<Query><SupportedFormats><Format revision='1'> urn:Microsoft.Search.Response.Document:Document" +
                            "</Format></SupportedFormats><Context><QueryText language='en-US' type='STRING'>");
            xmlString.Append(SharePointSearchString); // user entered text
            xmlString.Append("</QueryText></Context>");
            xmlString.Append("<Range><Count>5000</Count></Range>");
            xmlString.Append("</Query></QueryPacket>");
            System.Data.DataSet queryResults = queryService.QueryEx(xmlString.ToString());
DataTable dtResults = queryResults.Tables[0];
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.