【问题标题】:Xero API not working for Accounts in pythonXero API不适用于python中的帐户
【发布时间】:2020-10-07 22:36:01
【问题描述】:

我正在尝试在 python 中调用 xero Accounts api,但由于某种原因无法正常工作。它适用于发票、报告等其他 API,但 Accounts 除外。

以下脚本是我用来调用 api 的 python 脚本。

get_url = 'https://api.xero.com/api.xro/2.0/Accounts'   
response = requests.get(get_url,
                        headers = {
                            'Authorization': 'Bearer ' + access_token,
                            'Xero-tenant-id': xero_tenant_id,
                            'Accept': 'application/json'
                        })
json_response = response.json()
print(json_response)

但这会引发以下错误:

{'Type': None, 'Title': 'Unauthorized', 'Status': 401, 'Detail': 'AuthorizationUnsuccessful', 'Instance': '3c1649ef-6eed-4e64-8503-04fc99481db2', 'Extensions': {}}

谁能告诉我为什么会这样?为什么只是帐户?

【问题讨论】:

  • 问题可能是你使用了错误的 TenantID。尝试先调用租户 API 调用以获取 TenantID。

标签: python xero-api xero


【解决方案1】:

您能分享一下您要求的范围吗? https://developer.xero.com/documentation/oauth2/scopes

发票需要accounting.transactions 报告需要accounting.reports.read 帐号需要accounting.settings

【讨论】:

  • 是的,我忘记了accounting.settings。它现在正在工作。非常感谢@Rett Behrens
猜你喜欢
  • 2012-12-02
  • 1970-01-01
  • 1970-01-01
  • 2020-04-19
  • 1970-01-01
  • 2019-01-01
  • 2016-04-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多