Microsoft Graph API-批准审核请求

问题描述

我希望能够通过Graph API批准审核请求。我已提到Approve Moderation Request。我无法使其正常工作。虽然,EWS Managed API and Powershell How-To Series Part 11 Moderation 上有一个PowerShell脚本,我设法开始工作了。

这不是Graph API所支持功能,因此需要进行一些修补。我想要一些有关如何执行此操作的指导。

这是我要发送到终点https://graph.microsoft.com/v1.0/me/sendMail的JSON

{
    "message": {
        "subject": "Approve:MessageName"
    },"toRecipients": [
        {
            "emailAddress": {
                "name": "Microsoft Exchange","address": "systemmailBox@domain.com"
            }
        }
    ],"singleValueExtendedProperties": [
        {
            "id": "Binary 0x31","value": "7gd324tgcxJJNkEuxk2DP2Xk+M/fxw=="
        },{
            "id": "String 0x001A","value": "IPM.Note.Microsoft.Approval.Reply.Approve"
        }
    ]
}

这是我收到的回复

{
    "error": {
        "code": "ErrorInvalidRecipients","message": "At least one recipient isn't valid.,A message can't be sent because it contains no recipients.","innerError": {
            "date": "2020-08-19T23:40:07","request-id": "7g5h732v-6uhb-3212-b6f1-43f6eeb139wq"
        }
    }
}

任何帮助将不胜感激。

解决方法

您的Json请求中存在语法问题,例如,请仔细查看主题结束后的消息},这意味着您发布的唯一内容是消息的主题

{
    "message": {
        "subject": "Approve:MessageName","toRecipients": [
            {
                "emailAddress": {
                    "name": "Microsoft Exchange","address": "address.com"
                }
            }
        ],"singleValueExtendedProperties": [
            {
                "id": "Binary 0x31","value": "7gd324tgcxJJNkEuxk2DP2Xk+M/fxw=="
            },{
                "id": "String 0x001A","value": "IPM.Note.Microsoft.Approval.Reply.Approve"
            }
        ]
    }
}

其他

要使其正常工作,您需要从App漫游器邮箱获取批准请求,以供Graph这样的查询使用

https://graph.microsoft.com/v1.0/me/mailFolders('Inbox')/messages?$filter=singleValueExtendedProperties/any(ep:ep/id eq 'String 0x001a' and ep/value eq 'IPM.Note.Microsoft.Approval.Request')&$expand=singleValueExtendedProperties($filter%3D(Id eq 'Binary 0x0031') or (Id eq 'String 0x0E1D'))

这将为您提供在发送中需要使用的报告标记0x0031值,并且还需要包括“批准动词扩展”属性

{
                    id = "String {00062008-0000-0000-C000-000000000046} Id 0x8524"
                    value = "Approve"
 }

我从博客中转换了脚本,本周将继续发布该脚本,该脚本只批准邮箱中的最后一封电子邮件,您可以查看它https://github.com/gscales/Powershell-Scripts/blob/master/Graph101/Moderation.ps1(请参阅Invoke-ApproveModerationRequest)