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 :
Finance | Project Operations, Human Resources, ...
Answered

Deserializing root JSON attributes via D365 custom service.

(0) ShareShare
ReportReport
Posted on by 45

I'm working on a custom Dynamics service that I'm using to process webhook requests from a 3rd party vendor. The request body of the 3rd party vendors webhook is as follows...

pastedimage1634945945412v1.png

I have a custom service that looks like this...

pastedimage1634946021347v2.png

Dynamics does some magic with the auto deserializing of the request as long as the method parameter name matches a JSON node of the same name. In my case "event_type". If I name the method parameter "event_type" then that node of JSON will get deserialized into the associated contact class (PMSIApi_LobWebhookEventTypeDTO).

The problem I'm encountering is I can't figure out how to map root level JSON elements (red square) to a contract class as there is no root element name like "event_type" : { stuff } syntax in the JSON. The root elements are...

{

    "reference_id""ltr_b0b5b49352ac6889",
    "id""evt_d95ff8ffd2b5cfb4",
    "date_created""2016-12-04T22:50:08.180Z",

}

And not something like...

    "event_type": {
        "resource""letters",
        "enabled_for_test"true,
        "id""letter.mailed",
        "object""event_type"
    }

Which I can automagically map to the contract like...

pastedimage1634946594643v3.png

How can I deserialize those root level elements? Changing the JSON request body to wrap in something like { "request" : { all the stuff } } is not an option.

Thanks!

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,953 Most Valuable Professional on at

    It seems to me that your webbook() method should have four parameters. Not just event_type, but also reference_id, id and date_created.

  • jkmajcen Profile Picture
    45 on at

    That was it! Thanks so much Martin. Some real magic going on there.

  • Martin Dráb Profile Picture
    237,953 Most Valuable Professional on at

    As you see, the anonymous JSON object you're sending has properties correspinding to parameters of the method.

    By the way, please don't forget to mark the verified answer (by using Did this answer your question? > Yes).

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 592 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 478 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 305 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans