【发布时间】:2021-01-22 00:15:00
【问题描述】:
我需要使用 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}`
【问题讨论】:
-
你能发布完整的回溯吗?尝试删除
head和authorization行中的双引号,使它们看起来像head = {'Content-Type': 'application/json;charset=UTF-8'}和authorization = {'Authorization': 'Bearer '" + accessToken + "}
标签: python automation rpa microfocus