Teemee Tang

Teemee Tang

  • NA
  • 111
  • 9.8k

Error encountered when creating event in Microsoft Graph exp

Jul 2 2018 12:26 AM
Error encountered when creating event in Microsoft Graph explorer for c#
 
Error message:
StatusCode: 403, ReasonPhrase: 'Forbidden',
 
Codes :
  1. private static async Task<bool> CreateAppointmentAsync(HttpClient httpClient, EventModel eventModel)  
  2. {  
  3. var stringContent = JsonConvert.SerializeObject(eventModel);  
  4. string URL = GraphResource + GraphVersion + "/me/calendar/events";  
  5. var response = await httpClient.PostAsync(URL,  
  6. new StringContent(stringContent, Encoding.UTF8, "application/json"));  
  7. //var response = await httpClient.PostAsync(GraphResource + GraphVersion + "/me/events",  
  8. //new StringContent(stringContent, Encoding.UTF8, "application/json"));  
  9. return response.IsSuccessStatusCode;  
  10. }  
  11. Event model  
  12. public class EventModel  
  13. {  
  14. public string subject { getset; }  
  15. public Start start { getset; }  
  16. public End end { getset; }  
  17. public List<Attendees> Attendees { getset; }  
  18. }  
  19. public class Start  
  20. {  
  21. public DateTime dateTime { getset; }  
  22. public string timeZone { getset; }  
  23. }  
  24. public class End  
  25. {  
  26. public DateTime dateTime { getset; }  
  27. public string timeZone { getset; }  
  28. }  
  29. public class Attendees  
  30. {  
  31. public EmailAddress emailAddress { getset; }  
  32. public string type { getset; }  
  33. }  

Answers (1)