I'm trying to access the events of an Apple Calendar. So far I was able to call PROPFIND and get the Principal User. Now my question is how do I use the principal user to find the server? I have the xml request. I just want to know how to add the Principal User to the request header?
I followed thislink
This is how they say to get the server link:
PROPFIND /200385701/principal/ HTTP/1.1
Host: caldav.icloud
Content-Type: application/xml; charset=utf-8
Authorization: Basic basicValue
<d:propfind xmlns:d="DAV:" xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="/">
<d:prop>
<cal:calendar-home-set/>
<d:group-membership/>
</d:prop>
</d:propfind>
This is my XML request string:
string xmlRequest2 = "<?xml version=\"1.0\" encoding=\"utf-8\"?><d:propfind xmlns:d=\"DAV:\" xmlns:cal=\"urn:ietf:params:xml:ns:caldav\" xmlns:cs=\"/\"><d:prop><cal:calendar-home-set/><d:group-membership/></d:prop></d:propfind>";
This is the method that I pass it into:
private string GetPrincipalServer(string username, string password, string calendarURI, string xmlRequest, string principalName)
{
string principalServer = null;
Stream ResponseStream;
XmlDocument XmlDocument;
WebHeaderCollection whc = new WebHeaderCollection();
whc.Add(@"Translate", "F");
ResponseStream = ExectueMethod(username, password, calendarURI, "PROPFIND", whc, xmlRequest, "text/xml");
XmlDocument = new XmlDocument();
XmlDocument.Load(ResponseStream);
string xmlInner = XmlDocument.InnerXml;
XmlDocument innerXmlDocument = new XmlDocument();
innerXmlDocument.LoadXml(xmlInner);
XmlNodeList lst = innerXmlDocument.GetElementsByTagName("href");
principalServer = lst[lst.Count - 1].InnerText;
ResponseStream.Close();
return principalServer;
}
I think my code gets me part of the way there. I just don't know how to feed in the principal user which would actually give me the result that I need. In this example it is /200385701/principal/. So my question is how do I pass that into the header of my xml request?