【问题标题】:API PATCH request to move message using python in Micro Focus RPA在 Micro Focus RPA 中使用 python 移动消息的 API PATCH 请求
【发布时间】: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}`

【问题讨论】:

  • 你能发布完整的回溯吗?尝试删除 headauthorization 行中的双引号,使它们看起来像 head = {'Content-Type': 'application/json;charset=UTF-8'}authorization = {'Authorization': 'Bearer '" + accessToken + "}

标签: python automation rpa microfocus


【解决方案1】:

想通了:

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}

【讨论】:

    猜你喜欢
    • 2015-09-11
    • 2021-06-23
    • 1970-01-01
    • 1970-01-01
    • 2011-10-14
    • 1970-01-01
    • 2015-11-14
    • 2016-11-05
    相关资源
    最近更新 更多