我需要帮助,尝试使用 Python 对过去 24 小时内更新的票证发出以下请求,但根据提供的示例似乎无法弄清楚这一点。它在 Postman 中给了我一个有效的响应,所以 GET 请求有效,我只是无法弄清楚如何编码。
我试图做的查询是:https://clubready.zendesk.com/api/v2/search.json?sort_by=updated_at&sort_order=desc&query=updated>24hours type:ticket
我的代码是:
import requests
url = "https://clubready.zendesk.com/api/v2/search.json"
querystring = {"sort_by":"updated_at","sort_order":"desc","query":"updated%3E24hours%20type:ticket"}
payload = ""
headers = {
'Authorization': "Basic ZHJvYmluc29uQGNsdWJyZWFkeS5jb206QWNlbWFuMTAh",
'User-Agent': "PostmanRuntime/7.15.0",
'Accept': "*/*",
'Cache-Control': "no-cache",
'Postman-Token': "9d56b0e2-729f-4170-88f3-bcf9dbfa1020,803b5113-075b-4838-9fad-0d819c389c7a",
'Host': "clubready.zendesk.com",
'cookie': "__cfduid=d0076a9c776e07ff900489e935bb86e691558998542; __cfruid=03f547455e192905682b701e2bc5521a99d71c6c-1560442970; _zendesk_shared_session=-NEV5WTdPS1kyb1Z4SHBDbnk1d1dsWWhqUGloTTg1WEQybGs4L3FkNGRMakZtN0g3aGlTRlV1S3RrV1dlTllWWVFySUZvNkFFWHM5VVlEUDVyM0g1OFV3Q3grZjNIYWVwZGR1MlA4T05NN2NzZDlxMTZqUm0rNk9pVzFOSjk4M0I5SnB2d056MVNiZ28rWEdhMS9uQmhWT3g0MG1iaEtmVUpreTJzOXRRbVZHYUEvN1AyVk1KWkRtSzdiOVQvV2tkU0hia2VhenRCRjhGY3k1TTRFQ2dzUT09LS1BT2FIWEhzUXVwWGNxZ3lBcXBReklRPT0%3D--3c394a5133686509e48321137b451c2d037cf3ee; _help_center_session=NndtdTNYTDl3NTRWT1lLVGlLT1pYMVI4NVF5MncxOTVYdTlZWG1QTlJ5cGtTbXdPeGYyL2R6TWVwdXZXeUV6U2p3NlR0eHdnR29GOFlSMVpTalJvMUFRNCs1SkJqZHdJQXpOQzNveCtyT2xFU2pycGtUdEZRYWRnWHh1Z1YzcjFVWk5Ec1VoWjV0U2JXZGJTMURkT0djdnRiL3F6VlN2QU1IWDNSSVJRUTNuSm1mK21XZDdtSGhGaDc4bStsQzdIZ3dQeVVESW1sV3VaOGJuSjBjSjlBYWJ3a3J3bzEraHVDelJBclFtbk10RT0tLWMyTWxDNHpNQWcvVFRZbXo3R0szZkE9PQ%3D%3D--047ca57c1f10d81ce14f8de917a3ff6f43e9ef7b; _zendesk_session=BAh7C0kiD3Nlc3Npb25faWQGOgZFVEkiJWM3NjFiY2E5Zjc3YWVmMDg3Mjc2M2ZlNzk3MzYxZTFjBjsAVEkiDGFjY291bnQGOwBGaQKIAUkiCnJvdXRlBjsARmkDKzoBSSIOaXNfbW9iaWxlBjsAVEZJIhN3YXJkZW4ubWVzc2FnZQY7AFR7AEkiEF9jc3JmX3Rva2VuBjsARkkiRVlESmVEL1NWYVNhKzZ2YjRIRENaUGlBa29mdWtUZlArVU5QNEU3RXpTcjdhMlYwNG5OdzFVMU5INk1yY1pCTVoGOwBG--a237bcedbc9d391a74d2ad7b549bc7835b0e7566",
'accept-encoding': "gzip, deflate",
'Connection': "keep-alive",
'cache-control': "no-cache"
}
response = requests.request("GET", url, data=payload, headers=headers, params=querystring)
print(response.text)
{"results":[],"facets":null,"next_page":null,"previous_page":null,"count":0}
我在使用代码时得到了这个,但我在 Postman 中得到了一个实际的列表。