dygo
dygo

Reputation: 805

Google Calendar API : event description in HTML

I'm inserting the event into Google calendar and I can't find the way I can specify that description is not a plain text but the HTML markup:

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});

Upvotes: 1

Views: 4664

Answers (4)

Eileen Eby
Eileen Eby

Reputation: 41

after fighting with this for 48 hours, Renato's answer worked for me, and to include a url link, I coded it like this

    <a href=https://www.myweb.com/page.pdf>Page Description</a><br/>

Upvotes: 0

Renato Nascimento
Renato Nascimento

Reputation: 9

put description in a variable like this:

$variable = [
             "<span>Text here</span> <br/>
              <b>Text here</>
               ...           "
            ];

Upvotes: 1

dygo
dygo

Reputation: 805

There is only plain text available for Google Calendar Event description field. :-(

Upvotes: 0

Ecnalyr
Ecnalyr

Reputation: 5802

If you go to the documentation here, it speaks of setting the type (MIME). This means you probably just have to set the type to HTML.

Upvotes: 0

Related Questions