Python在使用Redtail API时接收响应401

2024-05-20 22:18:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我刚接触到API,在尝试连接到Redtail API时,我一直收到“响应401”。在

以下是一些关于Redtail的文档: https://help.redtailtechnology.com/hc/en-us/articles/203964430-Authentication-Methods-

我的密码是:

import requests
headers = {
'APIKey': '6C135EDF-C37C-4039-AEF3-5DFC079F9E6A',
'Username': 'Statementone',
'Password': 'sonedemo'
}
r = requests.get('https://api2.redtailtechnology.com/crm/v1/rest/', n 
headers=headers)
print(r)

任何帮助将不胜感激!在


Tags: 文档httpshccomapiauthenticationhelprequests
1条回答
网友
1楼 · 发布于 2024-05-20 22:18:08

提供凭据时,您需要使用base64编码并指定基本身份验证类型。在

注意:文档中的演示凭据似乎不再有效。另外,您使用的URL将返回404,因为它不是有效的URL。下面带有URL的示例将拉取所有联系人。在

import requests
import base64

APIKey = '6C135EDF-C37C-4039-AEF3-5DFC079F9E6A'
Username = 'Statementone'
Password = 'sonedemo'

token = APIKey + ':' + Username + ':' + Password
b64Val = base64.b64encode(token)

headers = {'Authorization': 'Basic %s' % b64Val}

r = requests.get('https://api2.redtailtechnology.com/crm/v1/rest/contacts', headers=headers)
print(r)

相关问题 更多 >