我插入事件到谷歌日历,我找不到我可以指定这样的描述是不是一个纯文本,但是HTML标记的方式:
request = WebRequest.Create("https://www.googleapis.com/calendar/v3/calendars/" + calendarID + "/events?pp=1&key=" + ClientID) as HttpWebRequest;
request.Headers.Add("Accept-Charset", "utf-8");
request.KeepAlive = true;
request.ContentType = "application/json";
request.Method = "POST";
request.Headers.Add("Authorization", "OAuth " + googleToken.ToString());
var actEvent = new GoogleCalendarEvent
{
summary = eventCalendar.Title,
description = eventCalendar.Description,
start = new GoogleCalendarEventTime(eventCalendar.Date),
end = new GoogleCalendarEventTime(eventCalendar.Date.AddHours(1))
};
var data = jsonSerializer.Serialize(actEvent);
var postData = Encoding.UTF8.GetBytes(data);
Stream ws = request.GetRequestStream();
ws.Write(postData, 0, postData.Length);
ws.Close();
response = request.GetResponse();
stream = new StreamReader(response.GetResponseStream());
var result = stream.ReadToEnd().Trim();
return Json(new {Success = true});