Skip to main content

Notifications

Service | Customer Service, Contact Center, Fie...
Suggested answer

Resolve the case in MS CRM through c#

Posted on by 5

I have a requirement to copy case and all associated metadata record from one environment to another. 

In same functionality, if a case is resolved on source environment then on target environment after copying the metadata I need to resolve the case. I am using c# console app to do this. 

public static void ResolveCase(CDSWebApiService svc, string targetEnv, string caseid)
{
try
{
var caseResolution = new JObject();
caseResolution.Add("incidentid_incident@odata.bind", "/incidents("   caseid   ")");
caseResolution.Add("description", "Resolved from system"); 
caseResolution.Add("Status ", -1);
caseResolution.Add("subject ", "Case Resolved");
// caseResolution.Add("IncidentResolution", caseResolution);
var closeincident = "https://wie"   targetEnv   ".crm.dynamics.com/api/data/v9.1/CloseIncident";
svc.PostCreate(closeincident, caseResolution);
}
catch (Exception ex)
{

throw;
}

}

But this code throws below error: An error occurred while validating input parameters: Microsoft.OData.ODataException: An OData property annotation was found for a parameter payload; however, parameter payloads do not support OData property annotations.

  • rajeshrai_work Profile Picture
    rajeshrai_work 5 on at
    RE: Resolve the case in MS CRM through c#

    Hi,

    Actually first i was following the same link, but it was not working. now. as you pointed out the same i tweak again my code to follow same. In below code first i create an entry of IncidentResolution entry and in this function now i am passing incidentResolutionid.

    public static void ResolveCase1(CDSWebApiService svc, string targetEnv, string resolutionid)

           {

               try

               {

                   JObject incidentResolution = new JObject()

                       {

                           { "subject", "Case Resolved" },

                           { "activityid@odata.bind", "/incidentresolutions(" + resolutionid + ")" }

                       };

                   JObject closeIncidentRequest = new JObject()

                       {

                           { "Status", -1 },

                           { "IncidentResolution", incidentResolution }

                       };

                   svc.PostCreate("CloseIncident", closeIncidentRequest);

               }

               catch (Exception ex)

               {

                   throw;

               }

           }

    But it's throwing this error

    An error occurred while validating input parameters: Microsoft.OData.ODataException: A property 'activityid' which only has property annotations in the payload but no property value is declared to be of type 'Edm.Guid'. In OData, only navigation properties and named streams can be represented as properties without values.

    Could you please help me to reach a conclusion?

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: Resolve the case in MS CRM through c#

    Hi,

    Closing/Resolving a case requires two step process. First we need to create Incident Resolution record and then second step is to use action Close Incident .

    Please see below blog for your reference.

    xrmdynamicscrm.wordpress.com/.../

    Please mark my answer verified if i were helpful

  • rajeshrai_work Profile Picture
    rajeshrai_work 5 on at
    RE: Resolve the case in MS CRM through c#

    Andrew, it's closing the case behind the scene, but on code side it throws this error "The given header was not found."

    I can handle the error but if we can solve this issue then it would be great.

    public static void ResolveCase(CDSWebApiService svc, string targetEnv, string caseid)

           {

               try

               {

                   JObject incidentResolution = new JObject()

                       {

                           { "subject", "Case Resolved" },

                           { "incidentid@odata.bind", "/incidents(" + caseid + ")" }

                       };

                   JObject closeIncidentRequest = new JObject()

                       {

                           { "Status", -1 },

                           { "IncidentResolution", incidentResolution }

                       };

                   svc.PostCreate("CloseIncident", closeIncidentRequest);

               }

               catch (Exception ex)

               {

                   throw;

               }

           }

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Resolve the case in MS CRM through c#

    Hello,

    The following line is incorrect:

    caseResolution.Add("incidentid_incident@odata.bind", "/incidents(" + caseid + ")");

    it should look like:

    caseResolution.Add("incidentid@odata.bind", "/incidents(" + caseid + ")");

    Also, the structure of the request object is incorrect. It should look like:

    {

    "IncidentResolution": {

       "subject": "Put Your Resolve Subject Here",

       "incidentid@odata.bind": "/incidents(put your guid here)",

       "description": "description here"

    },

    "Status": -1

    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans