Zendesk からデータを取得するための API 呼び出しを行う Python スクリプトがあります。(Python 3.x を使用) JSON オブジェクトの構造は次のようになります。
{
"id": 35436,
"url": "https://company.zendesk.com/api/v2/tickets/35436.json",
"external_id": "ahg35h3jh",
"created_at": "2009-07-20T22:55:29Z",
"updated_at": "2011-05-05T10:38:52Z",
"type": "incident",
"subject": "Help, my printer is on fire!",
"raw_subject": "{{dc.printer_on_fire}}",
"description": "The fire is very colorful.",
"priority": "high",
"status": "open",
"recipient": "support@company.com",
"requester_id": 20978392,
"submitter_id": 76872,
"assignee_id": 235323,
"organization_id": 509974,
"group_id": 98738,
"collaborator_ids": [35334, 234],
"forum_topic_id": 72648221,
"problem_id": 9873764,
"has_incidents": false,
"due_at": null,
"tags": ["enterprise", "other_tag"],
"via": {
"channel": "web"
},
"custom_fields": [
{
"id": 27642,
"value": "745"
},
{
"id": 27648,
"value": "yes"
}
],
"satisfaction_rating": {
"id": 1234,
"score": "good",
"comment": "Great support!"
},
"sharing_agreement_ids": [84432]
}
問題が発生している場所は、"custom_fields"
具体的にはセクションにあります。値が必要な各チケット内に特定のカスタム フィールドがあり、その特定の値のみが必要です。
Python コードの多くの詳細を省くために、以下の各チケットの各値を読み取り、それを出力変数に追加してから、その出力変数を .csv に書き込みます。破損が発生している特定の場所は次のとおりです。
output += str(ticket['custom_fields'][id:23825198]).replace(',', '')+','
すべてのナンセンスな置き換えは、コンマ区切りのファイルに入るため、値内のコンマが削除されていることを確認することです。とにかく、ここに私が得ているエラーがあります:
output += str(ticket['custom_fields'][id:int(23825198)]).replace(',', '')+','
TypeError: slice indices must be integers or None or have an __index__ method
ご覧のとおり、問題を解決するためにこれのいくつかの異なるバリエーションを試しましたが、まだ修正を見つけていません. 私はいくつかの助けを使うことができます!
ありがとう...