如何在zenpypython客户端库中将assignee设置为ticket

2024-05-29 07:11:57 发布

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

我正在使用Zenpy客户机在python库中集成Zendesk itsmapi。在

对于使用zenpy客户端创建票证,我可以通过电子邮件id设置票证的报告者,但对于受让者,我无法通过电子邮件id设置代理人

这是我迄今为止尝试过的代码。在

ticket_payload = Ticket(
    description="some description",
    type="task",
    priority="high",
    status="open"
    )

ticket_payload.requester = User(email="requester1@gmail.com"])
ticket_payload.assignee = User(email="assignee1@gmail.com")

response = self.zenpy_client.tickets.create(ticket_payload)

我得到的回复罚单上有记者设置,但assignee没有。在

如果我把身份证和电子邮件一起作为

^{pr2}$

然后它工作了,我可以看到assignee被设置为ticket。但记者不需要这样做。在

这是岑皮的不端行为,还是我遗漏了什么?在


Tags: comid客户机电子邮件emaildescriptionticketgmail
1条回答
网友
1楼 · 发布于 2024-05-29 07:11:57

我花了一段时间,但我想我理解你的问题。从“对象属性”部分下的API对象部分的文档中:

When the assignee attribute is accessed, Zenpy first attempts to locate the related User in the User cache and if it cannot be found will generate and execute an API call to retrieve, instantiate, cache and return the object.

我错误地认为这意味着我可以设置assignee属性的值,zenpy会查找它,然后将id放在assignee_id字段中。这是一种错误的解释。这句话的意思是,如果您设置了assignee_id,然后尝试访问assignee属性,它将查找并返回它。但一定有身份证

从文档的下一部分:

It is important to note that most property setters throw away all information except for the id. This is because Zendesk only expects the id, so any modifications made to the object will not be persisted automatically.

因此,当您设置没有id的受让人或请求者时,电子邮件地址将被丢弃,而相应的id被设置为None。在

至于为什么设置请求者ID,它可能被设置为您用来验证请求的用户,而不是您指定的用户。在

相关问题 更多 >

    热门问题