Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How to add RequiredAttendee and OptionalAttendee to Appointment in Dynamics 365 using REST API

Posted on by Microsoft Employee

Hello,

Trying to set RequiredAttendee and OptionalAttendee to Appointment using REST API. 

For example this code: 

var entity = {};
entity["activityid@odata.bind"] = "/activitypointers(533e8a14-fe33-e711-810e-c4346bac1938)";
entity["partyid_account@odata.bind"] = "/accounts(d7bd912f-4ee1-e611-8104-c4346bac1938)";
entity.participationtypemask = 5;

var req = new XMLHttpRequest();
req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/activityparties", 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) {
            var uri = this.getResponseHeader("OData-EntityId");
            var regExp = /\(([^)]+)\)/;
            var matches = regExp.exec(uri);
            var newEntityId = matches[1];
        } else {
            Xrm.Utility.alertDialog(this.statusText);
        }
    }
};
req.send(JSON.stringify(entity));

I receive error: 

"An undeclared property 'activityid' which only has property annotations in the payload but no property value was found in the payload. In OData, only declared navigation properties and declared named streams can be represented as properties without values."

How can I add RequiredAttendee and OptionalAttendee to Appointment usin REST API? Could you please share some working code with me? 

Thanks in advance,

Alexander

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to add RequiredAttendee and OptionalAttendee to Appointment in Dynamics 365 using REST API

    Solved:

    var entity = {};
    entity["appointment_activity_parties"] = [
        {
            "partyid_contact@odata.bind": "/contacts(d7bd912f-4ee1-e611-8104-c4346bac1938)",
            "participationtypemask": 5
        }
    ];
    
    var req = new XMLHttpRequest();
    req.open("PATCH", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/appointments(533e8a14-fe33-e711-810e-c4346bac1938)", 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(entity));


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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans