使用 Microsoft Graph API 添加自定义标头并检索自定义标头 [英] Add custom headers and retrieve custom header using Microsoft Graph API

查看:47
本文介绍了使用 Microsoft Graph API 添加自定义标头并检索自定义标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用 Microsoft Graph API 来检索我的电子邮件、发送新电子邮件和回复电子邮件.

I am currently using Microsoft Graph API to retrieve my email, send new email and answer to an email.

我使用代码授予授权来识别我的用户并访问其信息.

I use Code Grant authorization to identify my user and access its information.

问题

此应用程序让用户可以向我们的客户发送电子邮件,而这些客户的发票未付.但是该应用程序使用 GET https://graph.microsoft.com/v1.0/me/messages(将 $search 设置为客户电子邮件)来检索每封邮件这涉及到客户,因此用户可以跟踪其他员工的每一次对话.

This application let the user send email to our customers that have unpaid invoice. But the application uses GET https://graph.microsoft.com/v1.0/me/messages (with $search set to the customer email) to retrieve every mail that involves the customer, so the user can trace every conversation made by other employees.

问题是能够区分电子邮件(从我们的应用程序发送)与其他邮件(从 Outlook 应用程序发送).我们希望使用被大量邮件服务器接受的电子邮件标头,我们可以使用它过滤搜索结果以通知用户哪些电子邮件来自我们的应用.

The problem is to be able to differentiate emails (sent from our app) from others mails (sent from Outlook app). We would like to use email headers, which are accepted by a large amount of mail servers, and with which we could filter the search result to inform the user which email comes from our app.

所需的结果是,例如,我可以像这样调用 Microsoft Graph API :

The desired outcome would be that for example, I could be able to call Microsoft Graph API like so :

  1. GET https://graph.microsoft.com/v1.0/me/messages 使用 OData 参数:$search="john.doe@gmail.com"$select=subject,bodyPreviewreceivedDateTime,headers
  2. 然后假设请求已发回 200 代码,JSON 输出将是:
  1. GET https://graph.microsoft.com/v1.0/me/messages with OData Parameters : $search="john.doe@gmail.com" and $select=subject,bodyPreviewreceivedDateTime,headers
  2. Then asuming the request has send back a 200 code the JSON output would be :

请注意 X-MY-COMPANY-INVOICE,这将是我们让应用知道这是从我们的应用而非 Outlook 应用发送的最终目标.

Notice the X-MY-COMPANY-INVOICE, which would be the ultimate goal for us to let the app be aware this was sent from our app and not from Outlook app.

问题

有没有办法使用 Microsoft Graph API 执行此操作?如果没有,Microsoft 是否计划很快发布此功能?

Is there any way to perform this using Microsoft Graph API? If not, does Microsoft plan to release this feature any soon?

问题 2

我愿意接受建议,这是做到这一点的最佳方式还是我使用这种技术直接上墙?如果是,解决此问题的最佳方法是什么?

I am opened to suggestion, is this the best way to do this or am I going right on the wall with this technique? If yes, what would be the best way to overcome this issue?

推荐答案

这是 扩展.您可以使用这些机制将自定义数据附加到元素(消息、事件、用户、组等).

This is a good use case for Extensions. You can use these mechanisms to attach custom data to an element (messages, events, users, groups, etc.).

Microsoft Graph 提供多种类型的扩展:扩展属性开放扩展架构扩展.每个都有它自己的一组约束,因此值得查看每个约束以确定最适合您的场景和架构的约束.也就是说,根据您的描述,我怀疑 Schema Extensions 可能最适合这里.

There are several types of extensions available with Microsoft Graph: Extended Properties, Open Extensions or Schema Extension. Each has it's own set of constraints so it is worth reviewing each to determine which works best for your scenario and architecture. That said, based on your description, I suspect Schema Extensions may be the best fit here.

这篇关于使用 Microsoft Graph API 添加自定义标头并检索自定义标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆