更改simple-salesforce库中的路径



我试图通过simple_salesforce库在python中获得我在SalesForce上创建的报告。我能够成功连接。但是,我得到无效的会话id错误,因为链接是错误的,这是由simple_salesforce创建的。我试图获得的url与simple_salesforce正在搜索的url不同(在下面的错误中给出)。

我要获取的链接是:"https://gkg-mfsa.lightning.force.com/lightning/r/Report/00O9N000000JwK2UAK/view?queryScope=userFolders">

但是simple_salesforce正在搜索的链接是:"https://gkg-mfsa.my.salesforce.com/services/data/v42.0/lightning/r/Report/00O9N000000JwK2UAK/view?queryScope=userFolders"(如错误所示)

如何让simple_salesforce库搜索我想要获得的链接,而不是它寻找的链接。

from simple_salesforce import Salesforce

sf = Salesforce(username='myUserName', 
password='myPassword',
security_token='mySecurityToken',
instance_url = "")
report_id = 'myreportId'
sf.restful("lightning/r/Report/ + reportId + /view?queryScope=userFolders")

输出
SalesforceExpiredSession: Expired session for https://gkg-mfsa.my.salesforce.com/services/data/v42.0/lightning/r/Report/00O9N000000JwK2UAK/view?queryScope=userFolders. Response content: [{'message': 'This session is not valid for use with the REST API', 'errorCode': 'INVALID_SESSION_ID'}]

从成功的登录调用中获取会话id和基本端点

session_id, instance = SalesforceLogin(
username='myemail@example.com',
password='password',
security_token='token')

然后手动运行REST请求。但是您必须将会话id作为cookie传递,而不是作为"授权承载者"传递。http报头。

中有一个例子https://github.com/simple-salesforce/simple-salesforce/issues/584

我以前的一个答案(显示原始http,但仍然,应该给你一个想法)https://stackoverflow.com/a/56162619/313628, https://stackoverflow.com/a/57745683/313628

最新更新