I really hate it when problems happen for no reason (?), but I have one that I need some help with. We download shared ICS calendars from a public URL into our application, which was working for both Gmail and O365 for several years, until last week when the O365 link started throwing 400 (bad request errors).
Can anyone shed any light on why Google works and O365 doesnt ?
I suspect this is problem with O365 but I need to really prove it
using System;
using System.IO;
using System.Net;
namespace ICS_Test
{
internal class Program
{
static void Main(string[] args)
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
string myGmail = "https://calendar.google.com/calendar/ical/smilecrmtesting1%40gmail.com/public/basic.ics";
string myOutlookRaw = "https://outlook.office365.com/owa/calendar/8550986f6c8f45edbe3c66ddb0c24d09@1stconsulting.com/fa89bfda91684ed28ed3cb6708c6fb1a13982551512168918431/calendar.ics";
string fileName = "calendar.ics";
// this bit works
Uri myUriGmail = new Uri(myGmail);
using (var client = new WebClient())
{
client.DownloadFile(myUriGmail, "C:/Temp/" + fileName);
}
// this fails with 400 error - BUT if you drop the link into a browser it works
Uri myUriO365 = new Uri(myOutlookRaw);
using (var client = new WebClient())
{
client.DownloadFile(myUriO365, "C:/Temp/" + fileName);
}
}
}
}