views:

2238

answers:

3

Is it possible to get a list of events (with recurring events expanded) out of Sharepoint's Calendar using the Web Service exposed through Lists.aspx?

This is evidently possible if you are using C# or VB, as described here using a snippet like this:

SPQuery query = new SPQuery();
query.ExpandRecurrence = true;
query.Query = "<Where><DateRangesOverlap><FieldRef Name=\"EventDate\" /><FieldRef Name=\"EndDate\" /><FieldRef Name=\"RecurrenceID\" /><Value Type=\"DateTime\"><Month /></Value></DateRangesOverlap></Where>";

I am trying to do the same using plain XML via cURL with this query:

<GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"&gt;
<listName>{my guid goes here}</listName>
<query>
 <Query xmlns="">
 <Where>
 <DateRangesOverlap>
   <FieldRef Name="EventDate" />
   <FieldRef Name="EndDate" />
   <FieldRef Name="RecurrenceID" />
   <Value Type="DateTime"><Month/></Value>
   </DateRangesOverlap>
 </Where>
 </Query>
</query>
<queryOptions>
 <QueryOptions>
 <ExpandRecurrence>TRUE</ExpandRecurrence>
 </QueryOptions>
</queryOptions>

This kinda works - it gets all the list items, but recurring items are not expanded. The key seems to be the ExpandRecurrence property. Surprisingly, Google does not seem to have a lot to say on the matter beyond a couple of blog posts. Scouring the web, I've read a few comments indicating that the ExpandRecurrence property does not work, but others say it works fine and nothing I've read has struck me as definitive.

Has anybody tried this and gotten it to work without using C# or VB - just straight XML?

A: 

The way I would track down this problem would be to use something like TcpTrace (http://www.pocketsoap.com) to look at the XML packets being sent. Then it is a matter of making sure the hand-crafted XML packet looks the same. I'm hoping that when you see the XML packet, the difference should be obvious. Then you can update this question with the answer.

Tommy Hui
A: 

I have the same problem. Do you solve it? I tracked the the XML packets with Fiddler and everything seems correct. Any other ideas?

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;soap:Body&gt;&lt;GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"&gt;&lt;listName&gt;Calendar&lt;/listName&gt;&lt;viewName&gt;&lt;/viewName&gt;&lt;query&gt;&lt;Query&gt;                                 <Where>                                     <DateRangesOverlap>                                         <FieldRef Name="EventDate" />                                         <FieldRef Name="EndDate" />                                         <FieldRef Name="RecurrenceID" />                                         <Value Type="DateTime">                                             <Month />                                         </Value>                                     </DateRangesOverlap>                                 </Where>                             </Query></query><viewFields></viewFields><rowLimit>50</rowLimit><queryOptions><QueryOptions>                                        <ExpandRecurrence>TRUE</ExpandRecurrence>                                     </QueryOptions></queryOptions><webID></webID></GetListItems></soap:Body></soap:Envelope>
No. I never figured it out. It *seems* like the ExpandRecurrence simply must be done server-side. Depending on your situation, you may be able to create a Web Service wrapper that mimics the normal Calendar web service, but explicitly handles the ExpandRecurrence flag. That's my only guess so far.
allclaws
+2  A: 

Nope is not possible. You would need to use the SP Object model via, for example the SPQuery object. But that would mean that you would have to run that code directly on the sharepoint server, instead of calling in from a client.

Please see this post of mine; http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/3c399768-c492-4d7e-8f6e-fa304ed03131

Frenske