MS Graph日历API |如何建立活动?

问题描述

我点击了教程链接:https://docs.microsoft.com/en-us/graph/tutorials/node

除其他外,我有2个文件graph.js和calendar.js。

我想使用post方法创建一个事件。

跟随此链接:https://docs.microsoft.com/en-us/graph/api/user-post-events?view=graph-rest-1.0&tabs=http

以及上述教程中介绍的Get方法,我为每个文件(graph.js和calendar.js)创建了2个代码段

Graph.js代码段:

  postEvents: async function(accessToken){
    const client = getAuthenticatedClient(accessToken);


    const event1 = {
      subject: "Let's go for lunch",body: {
        contentType: "HTML",content: "Does noon work for you?"
      },start: {
          dateTime: "2020-08-15T12:00:00",timeZone: "Pacific Standard Time"
      },end: {
          dateTime: "2020-08-15T14:00:00",organizer: [
        {
          emailAddress: {
            address:"samanthab@contoso.onmicrosoft.com",name: "Samantha Booth"
          },type: "required"
        }
      ],allowNewTimeProposals: true
    };


    const events_post = await client
      .api('/me/events')
      .post(event1)
      
    console.log(events_post)
    return events_post; //console.log
    
  }

calendar.js代码段:

router.post('/',async function(req,res) {
    if (!req.isAuthenticated()) {
      // Redirect unauthenticated requests to home page
      res.redirect('/')
    } else {
      let params = {
        active: { calendar: true } //The active selector is used to select and style the active link
      }; //The Calendar class is an abstract class that provides methods for converting between a specific instant in time and a set of calendar fields 

      // Get the access token
      var accessToken;
      try {
        accessToken = await tokens.getAccessToken(req);
      } catch (err) {
        req.flash('error_msg',{
          message: 'Could not get access token. Try signing out and signing in again.',debug: JSON.stringify(err)
        });
      }

      if (accessToken && accessToken.length > 0) {
        try {
          // post the event
          var event = await graph.postEvents(accessToken);
          params.event = event.value;
        } catch (err) {
          req.flash('error_msg',{
            message: 'Could not post events',debug: JSON.stringify(err)
          });
        }
      } else {
        req.flash('error_msg','Could not get an access token');
      }

      res.render('calendar',params);
    }
  }
);

但是该事件未在我的Outlook日历中创建。 谁能帮我解决这个问题? 我是node.js,javascript和API概念的新手。 我也无法在控制台中看到日志。 (此权限相关吗?)

如果需要更多详细信息,请问我。

谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...