Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

Create & Update Events through API

Posted on by

Hello,

We have a custom web application that manage events and we try to make it sync with our D365 Marketing Event management system.

Events are created and managed in our custom web app.

Through API, we can retrieve all events of D365 :

GET https://xxx.dynamics.com/api/data/v9.2/msevtmgt_events?$select=msevtmgt_eventid,msevtmgt_name&$count=true

We can also retreive single event (filter by eventid) :

GET https://xxx.dynamics.com/api/data/v9.2/msevtmgt_events?$filter=(msevtmgt_eventid eq xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
or
GET https://xxx.dynamics.com/api/data/v9.2/msevtmgt_events(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)

But we are unable to create or update an event :

PATCH https://xxx.dynamics.com/api/data/v9.2/msevtmgt_events(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
data = {
  "msevtmgt_name":"Test",
  "tc_venue":"My best place"
}

(same with data in JSON or form-data format)

We got this error :

The requested resource does not support http method 'PATCH'

And with POST method :

Unmapped Request found, PathTemplate:~/entityset/key, HtppVerb:POST

We try also through webhook :

POST https://xxxxxxxxxxxxxx.svc.dynamics.com/EvtMgmt/api/v2.0/events/{readableEventId}?emApplicationtoken=xxxxxxxxxx
data = {
    "eventName":"Test"
}

And we got 404 error... (same with PATCH method)

Maybe someone has an idea to help us ?

Thanks in advance,

Serge

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Create & Update Events through API

    Hi databird,

    I created a web resource and insert it into form to test:

    <html>
    <head>
    <title>test</title>
    <script src="ClientGlobalContext.js.aspx" type="text/javascript"></script>
    <meta><meta><meta><meta><meta><meta><meta></head>
    <body onload="updateEvent()" style="overflow-wrap: break-word;">
    <div>
    test
    </div>
    </body>
    <script type="text/javascript">

    function updateEvent(){
    data = {
    "msevtmgt_name":"Test",
    "msevtmgt_maximumeventcapacity":1
    }
    var uri = "">xxxxxxxx.crm.dynamics.com/.../msevtmgt_events(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)";
    var request = new XMLHttpRequest();
    request.open("PATCH", uri , true);
    request.setRequestHeader("OData-MaxVersion", "4.0");
    request.setRequestHeader("OData-Version", "4.0");
    request.setRequestHeader("Accept", "application/json");
    request.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    request.onreadystatechange = function () {
    if (request.readyState === 4) {
    console.log("success");
    }
    }
    request.send(JSON.stringify(data));
    }
    </script>
    </html>

    And it can work:

    pastedimage1634198554299v1.png

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