1

我需要使用 Micro Focus Robotic Process Automation 应用程序创建一个 PATCH 请求以将电子邮件移动到不同的文件夹中。此应用程序的语法与普通 python 不同,我无法弄清楚。

如果我删除了“head”行、“authorization”行以及“response”行中“header”和“authorization”的调用,则以下内容有效

但显然它返回 401 的代码,因为没有授权。

授权部分抛出此错误:'str' object is not callable
标头部分抛出此错误:'str' object has no attribute 'items

代码从这里开始:

import importlib
requests = importlib.import_module('requests')
json = importlib.import_module('json')
url = 'https://graph.microsoft.com/v1.0/users/{{account account}}/messages/' + messageID
body = "{'subject':" + careRecordNum + "' - Thank you for your enquiry. Ref: 1046120'}"
head = "{'Content-Type': 'application/json;charset=UTF-8'}"
authorization = "{'Authorization': 'Bearer '" + accessToken + "}"


response = requests.patch(url, data=json.dumps(body), headers=head, auth=authorization)
return {'response':response}`
4

1 回答 1

0

弄清楚了:

def execute(messageID, accessToken): 
    import importlib
    requests = importlib.import_module('requests')

url = 'https://graph.microsoft.com/v1.0/users/{{user}}/messages/' + messageID + '/move'
body = "{\"destinationId\":\"{{folderID}}\"}"
head = {"Content-Type": "application/json;charset=UFT-8", "Authorization": "Bearer " + accessToken}

response = requests.post(url, data=body, headers=head)
return {'response':response}
于 2020-10-21T04:55:25.987 回答