Notifications
Announcements
No record found.
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
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.
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.
Roman,
If my reply answers your question feel free to mark it as answer.
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
Ok, what code do you use?
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
Can you please provide the code you use?
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}"); } }
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?
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:
I tested the query with CRM Rest Builder, with the same GUID and as you can see I got many calendar rules:
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2