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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Close case through web api

(0) ShareShare
ReportReport
Posted on by 2,510

Hi, I am following this post to close a case through web api. However, when I call this action through browser, it gave me the error, but it is available in metadata, 

butenko.pro/.../close-incident-using-webapi

2727.Capture.PNG

2046.error.PNG

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Gopalan Bhuvanesh Profile Picture
    11,401 on at

    Hi

    Please check your URL is correct.

    You can obtain this url from

    Developer Resources (Settings -> Customization)

    Service Root Url in the Instance Web API  section

  • sdnd2000 Profile Picture
    2,510 on at

    Can we close the incident by workflow without any coding work?

  • sdnd2000 Profile Picture
    2,510 on at

    I believe the URL is correct, since I can request other api through it.

  • Suggested answer
    Community Member Profile Picture
    on at

    Are you trying GET method using browser?

    If so, can you try with POST.

    Regards,

    Charmis

  • sdnd2000 Profile Picture
    2,510 on at

    I just put this url in browser, what else I can try

    dev1.xxxx.test/.../closeincident

    dev1.xxxx.test/.../accounts, this comes with json data, so I believe the URL should be good

  • Suggested answer
    Gopalan Bhuvanesh Profile Picture
    11,401 on at

    Hi

    As mentioned it is a POST method.

    Replace the code as below. You can also get the record id from the form using Xrm.Page.data.entity.getId();

    The JavaScript code works fine. Use the code in the link and update the code as below to have the case Id of the current record.

    butenko.pro/.../close-incident-using-webapi

        var caseId = Xrm.Page.data.entity.getId();
        caseId = caseId.replace("{", "").replace("}", "");
        var incidentresolution = {
            "subject": "Put Your Resolve Subject Here",
            "incidentid@odata.bind": "/incidents(" + caseId + ")",//Id of incident
            "timespent": 60,//This is billable time in minutes
            "description": "Additional Description Here"
        };
  • Verified answer
    Gopalan Bhuvanesh Profile Picture
    11,401 on at

    I have added the modified code.

  • Suggested answer
    Community Member Profile Picture
    on at

    FYI

    var parameters = {};

    var incidentresolution = {};

    incidentresolution.primarykeyid = "00000000-0000-0000-0000-000000000000";

    incidentresolution["@odata.type"] = "Microsoft.Dynamics.CRM.incidentresolution";

    parameters.IncidentResolution = incidentresolution;

    parameters.Status = 0;

    var req = new XMLHttpRequest();

    req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/CloseIncident", true);

    req.setRequestHeader("OData-MaxVersion", "4.0");

    req.setRequestHeader("OData-Version", "4.0");

    req.setRequestHeader("Accept", "application/json");

    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

    req.onreadystatechange = function() {

       if (this.readyState === 4) {

           req.onreadystatechange = null;

           if (this.status === 204) {

               //Success - No Return Data - Do Something

           } else {

               Xrm.Utility.alertDialog(this.statusText);

           }

       }

    };

    req.send(JSON.stringify(parameters));

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    melvin fong just curious - have you tried that code or just copy-pasted from CRM Rest Builder? Try to run it and you will see that your code doesn't work. At all.

  • Community Member Profile Picture
    on at

    agree with you. the piece of codes doesn't work at all. I am still looking for some useful online resource that provides a good wrapper to call those actions and functions via Web API.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans