Sidhu
Sidhu

Reputation: 35

How to call FullTextSearchKnowledgeArticle action using REST calls?

How can we call MSCRM action using some HTTP Client request (c#)? Can any one please assist on this.

Upvotes: 0

Views: 323

Answers (3)

praveen thonda
praveen thonda

Reputation: 3

Take this for an answer I could finally figure it out from the below Power Apps Sample for WebAPI which helped me figure out how to supply values of conditional expression inside query expression. https://github.com/microsoft/PowerApps-Samples/blob/efd91060156ecca74fd674a4613a38b64df13858/dataverse/webapi/C%23-NETx/BulkOperations/Utility.cs

{
"QueryExpression": {
    "@odata.type": "Microsoft.Dynamics.CRM.QueryExpression",
    "ColumnSet": {
        "Columns": ["title", "description", "content"]
    },
    "Criteria": {
        "Conditions": [{
                "AttributeName": "languagelocaleid",
                "EntityName": "knowledgearticle",
                "Operator": "Equal",
                "Values": [{
                        "Type": "System.Guid",
                        "Value": "d026c011-4c03-4bfd-93d7-017f480ed54d"
                    }
                ]
            }
        ],
        "FilterOperator": "And"
    },
    "Distinct": false,
    "EntityName": "knowledgearticle",
    "NoLock": false,
    "PageInfo": {
        "Count": 100,
        "PageNumber": 1,
        "PagingCookie": "",
        "ReturnTotalRecordCount": true
    }
},
"RemoveDuplicates": false,
"SearchText": "book",
"StateCode": 3,
"UseInflection": true

}

Upvotes: 0

Gareeb Navas
Gareeb Navas

Reputation: 70

Make a POST request to the the following URL.

[Your organization root URL]/api/data/v9.1/FullTextSearchKnowledgeArticle

Here is one sample payload that works. You can optionally add additional filters to filter the search result.

{
   "SearchText":"test",
   "UseInflection":true,
   "RemoveDuplicates":true,
   "StateCode":3,
   "QueryExpression":{
      "@odata.type":"Microsoft.Dynamics.CRM.QueryExpression",
      "EntityName":"knowledgearticle",
      "ColumnSet":{
         "AllColumns":true
      },
      "PageInfo":{
         "PageNumber":1,
         "Count":10
      },
     "Orders":[
         {
            "AttributeName":"modifiedon",
            "OrderType":"Descending"
         }
      ]
   }
}

Refer the link below for sample code for connecting to Dynamics. CDSWebApiService class library (C#)

Upvotes: 0

The documentation is not covering this action, and I was able to pull this payload from couple of references. But I could not test this in my environment, please test it yourself.

The sample will look like this:

{
  "SearchText": "",
  "UseInflection": false,
  "RemoveDuplicates": false,
  "StateCode": 3,
  "QueryExpression": {
    "@odata.type": "Microsoft.Dynamics.CRM.QueryExpression",
    "EntityName": "knowledgearticle",
    "ColumnSet": {
      "AllColumns": true
    },
    "Distinct": false,
    "NoLock": false,
    "PageInfo": {
      "PageNumber": 1,
      "Count": 10,
      "ReturnTotalRecordCount": true,
      "PagingCookie": ""
    },
    "LinkEntities": [],
    "Criteria": {
      "FilterOperator": "And",
      "Conditions": [
        {
          "EntityName": "knowledgearticle",
          "AttributeName": "languagelocaleid",
          "Operator": "Equal",
          "Values": [
            "56940B3E-300F-4070-A559-5A6A4D11A8A3"
          ]
        }
      ]
    }
  }
}

Reference.

Upvotes: 0

Related Questions