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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

WebApi retrieve Calendar with CalendarRules

(0) ShareShare
ReportReport
Posted on by 85

Exist any way how i can retrieve Calendar with Calendar Rules with webapi?

With SOAP service i can retrieve Calendar with rules in array.

*This post is locked for comments

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

    Hello Roman,

    I tried following query and everything worked fine for me:

    someorgname.crm.dynamics.com/.../calendars(b8f2c05a-bf28-e711-8111-fc15b428771c)$expand=calendar_calendar_rules

    Of course you will have to replace calendar id with yours.

  • Suggested answer
    RomanV Profile Picture
    85 on at

    I solved it before, and forgot write here :(.

    I tryed select retrieved atribute i needed (InnercalendarId) but always got error message "The navigation properties are not supported with $select clause". When i retrieve all attribute, everyuthing work.

    Thanks anyway.

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

    Roman,

    If my reply answers your question feel free to mark it as answer.

  • Daniel Serrano Profile Picture
    on at

    Hi Andrew, your URL is no longer available. Is there any solution for this? I am trying to get Calendar data from an Azure Function but it doesn't retrieve me any attributes

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

    Ok, what code do you use?

  • Daniel Serrano Profile Picture
    on at

    Thank you for your answer.

    So basically I am using an Azure Fn coded with C#. What I want to achieve is to retrieve calendars by their related bookable resource, but when I make that query using Web API, I receive a record with all the values null.

    Another problem is that if I make that query selecting the attribute “calendarrules” it fails with an error saying that could not find that attribute, but it should right?

    Best regards,

    Daniel Serrano

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

    Can you please provide the code you use?

  • Daniel Serrano Profile Picture
    on at

    Ok, the code is:

    public Calendar GetCalendarById(Guid calendarId)
            {
                try
                {
                    var result = Task.Run(async () => await _webApi.Get(Calendar.EntitySetName, calendarId));
                    
                    return result.Result;
                }
                catch (Exception e)
                {
                    throw new Exception($"Retrieve Calendar error: {e.Message}");
                }
            }

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

    Calendar Rules are under "expand", I see Filter, Select e.t.c. but I don't see "Expand".

    Also, I don't know what's under the hood of the framework you use. Can you please provide the end result - WebApi request that will be sent to WebApi?

  • Daniel Serrano Profile Picture
    on at

    Thank you once again for your answear.

    You are right, I should use expand options. I also found that I need to use an ExpandoObject because the conversion between ExpandoObject and Calendar was resulting on an empty Calendar entity, so I will build the convertor myself.

    The only problem now, is that the calendar rules are still empty, as you can see from the image below:

    pastedimage1623684836019v1.png

    I tested the query with CRM Rest Builderwith the same GUID and as you can see I got many calendar rules:

    pastedimage1623685152123v1.png

    This is the code I am now using:

    var result = Task.Run(async () => await _webApi.GetList(Calendar.EntitySetName, new CRMGetListOptions
                    {
                        Filter = $"calendarid eq {calendarId}",
                        Select = new string[] { "calendarid", "_businessunitid_value" },
                        Expand = new CRMExpandOptions[]
                           { new CRMExpandOptions()
                                { Property="calendar_calendar_rules",
                                  Select = new string [] {"businessunitid"},
                                }
                           }
                    })).Result.List[0];

    I am using the API helper from Davidyack's github: https://github.com/davidyack/Xrm.Tools.CRMWebAPI/tree/1d89792291b435cf659932bdc8e54662c7ddf4b7/dotnet

    I can not get the full result of the Web Api Request to show you, but I checked his code and everything looks well built.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans