I am referencing the Microsoft Docs https://docs.microsoft.com/en-us/graph/api/calendar-getschedule?view=graph-rest-1.0&tabs=http
I'm trying to send a request to https://graph.microsoft.com/v1.0/me/calendar/getSchedule.
I get a successful response but sometimes the API is very slow, especially on the initial page load where it can take more than 10 seconds. When I send the request again, however, it only takes 0.3 seconds.
Below is my send request code
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
WebRequest request = WebRequest.Create(
" https://graph.microsoft.com/v1.0/me/calendar/getSchedule ");
string param = "{\"schedules\":[\"" + userPrincipalName + "\"],";
param += "\"startTime\" : {\"dateTime\": \"" + startTime
+ "\",\"timeZone\": \"Taipei Standard Time\"},";
param += "\"endTime\" : {\"dateTime\": \"" + endTime
+ "\",\"timeZone\": \"Taipei Standard Time\"},";
param += "\"availabilityViewInterval\" : 60}";
request.Method = "POST";
request.ContentType = "application/json";
request.Headers["Authorization"] = " Bearer " + token;
request.Headers["Prefer"] = "outlook.timezone=\"Taipei Standard Time\"";
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
streamWriter.Write(param);
}
try
{
var httpResponse = (HttpWebResponse)request.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
WebUtility.WriteAjaxResult(true, null, result);
}
}
I hope someone can answer the reason for me, thanks!

