【问题标题】:Getting Response Code as 500 when hitting Rest API in Python在 Python 中点击 Rest API 时将响应代码设为 500
【发布时间】:2019-03-13 07:51:40
【问题描述】:

我正在使用 requests.get() 来调用 REST api。当我对 URL 进行硬编码时,它工作正常,但如果我在帐户名称后附加 URL,则响应代码为 500。请帮助。

    header = {'Authorization': token_type + " " + token, 'Content-Type': 'application/json'}
    account_name="test_account"
    uri = "https://my_instance.salesforce.com/services/apexrest/account/entitlement?AccountName="+account_name
    user_create_res = requests.get(uri, headers=header)

但是当我给出相同的代码时,

header = {'Authorization': token_type + " " + token, 'Content-Type': 'application/json'}
uri = "https://my_instance.salesforce.com/services/apexrest/account/entitlement?AccountName=test_account"
user_create_res = requests.get(uri, headers=header)

【问题讨论】:

    标签: python rest python-requests salesforce


    【解决方案1】:

    尝试使用

    打印 account_name 变量
    print(account_name)
    

    确保控制台中记录的文本与您尝试硬编码的名称相同。


    虽然也可能是 account_name 变量不是字符串。


    我不能确定我是否没有获得更多信息,例如您在哪里定义 account_name 变量。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-05
      • 2017-06-14
      • 2014-02-10
      • 1970-01-01
      • 2016-03-23
      相关资源
      最近更新 更多