【问题标题】:When using Node.js with the graph API I can't seem to add the @odata.id to the object将 Node.js 与图形 API 一起使用时,我似乎无法将 @odata.id 添加到对象
【发布时间】:2020-12-26 22:08:29
【问题描述】:

我一直在编写一个 node.js Java 脚本来查看 MSFT 图形信息。我正在尝试将所有者发布到可以使用网站上的 Https 帖子的组中。但是,当我尝试运行 Node Is 代码时出现错误。我似乎对这个对象有疑问:

const directoryObject = {
  @odata.id: "https://graph.microsoft.com/v1.0/users/{id}"
};

JavaScript 似乎不喜欢对象键中的 @ 或 。

https://docs.microsoft.com/en-us/graph/api/group-post-owners?view=graph-rest-1.0&tabs=http

JavaScript 代码 sn-p :

常量选项 = { 身份验证提供者, };

const client = Client.init(options);

 const directoryObject = {
  @odata.id: "https://graph.microsoft.com/v1.0/users/{id}"
};

let res = await client.api('/groups/{id}/owners/$ref')
    .post(directoryObject);

非常感谢

多米尼克

【问题讨论】:

    标签: node.js microsoft-graph-sdks


    【解决方案1】:

    好吧,虽然我不确定是什么修复了它,但我设法让事情正常工作,但我做了 3 件事:

    1. 微软节点。 JS代码不起作用,你只需要把语音标记放进去,看起来像:

      常量目录对象 = { "@odata.id": "https://graph.microsoft.com/v1.0/users/{id}" };

    2. 我还添加了 odata 模块:

      npm install odata

      这里有更多信息:

      1.https://www.npmjs.com/package/odata 2.http://olingo.apache.org/doc/javascript/apidoc/json.html 3.https://www.odata.org/getting-started/understand-odata-in-6-steps/ 4.https://www.odata.org/getting-started/basic-tutorial/

    3. 我使用 MSFT 图表示例中的 .post 示例发布日历事件并对其进行了调整。我也没有检查代码中的 html 响应,查看了终端响应并检查了 Teams 中的行为。

    【讨论】:

      猜你喜欢
      • 2021-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-02
      • 2019-01-30
      • 2013-02-25
      • 2018-02-19
      相关资源
      最近更新 更多