web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Suggested Answer

Resolve the case in MS CRM through c#

(0) ShareShare
ReportReport
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.

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    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

    }

  • rajeshrai_work Profile Picture
    5 on at

    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
    Bipin D365 Profile Picture
    28,985 Moderator on at

    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
    5 on at

    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?

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 51 Super User 2026 Season 1

#1
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 51 Most Valuable Professional

#3
Nagaraju_Matta Profile Picture

Nagaraju_Matta 50

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans