import msal
from office365.graph_client import GraphClient
import json
import requests
import urllib3
authority_url = 'https://login.microsoftonline.com/ae4df1f7-611e-444f-897e-f964e1205171'
authority=authority_url,
app = msal.ConfidentialClientApplication(
client_id = '------',
client_credential = '-----'
)
token = app.acquire_token_for_client(scopes=["https://graph.microsoft.com/.default"])
data = json.dumps(token)
dict1= json.loads(data)
token_value = dict1["access_token"] ##Able to obtain the token
url = 'https://graph.microsoft.com/v1.0/users/sharedmailbox@xyz.com/mailFolders/Inbox/messages/59f3b86064fc4590969f468bbffe323c@MW4PR15MB3453.namprd15.prod.outlook.com'
headers = {
'authorization': "Bearer " + token_value,
}
response = requests.delete(url, headers=headers)
print(response)
我收到
答案 0 :(得分:0)
来自行
url = 'https://graph.microsoft.com/v1.0/users/sharedmailbox@xyz.com/mailFolders/Inbox/messages/59f3b86064fc4590969f468bbffe323c@MW4PR15MB3453.namprd15.prod.outlook.com
看起来您尝试使用 InternetMessageId 删除无效的 Message,您需要找到底层 ItemId(即 Exchange Mid)。如果您只有 InternetMessageId,则首先使用过滤器来查找它,例如
https://graph.microsoft.com/v1.0/users/sharedmailbox@xyz.com/mailFolders/Inbox/messages/$filter=internetMessageId eq '%3C59f3b86064fc4590969f468bbffe323c%40MW4PR15MB3453.namprd15.prod.outlook.com%3E'
InternetMessageId(无论如何来自 Office365 的那些)总是包含在 <> 中,因此您需要包含然后转义它。您需要获取从您的搜索返回的 Base64 id 属性,然后使用它。