我使用Go和Zendesk API来代表用户创建ticket,但我不希望创建ticket的邮件发送给用户。有没有办法做到这一点?下面是我的实现:
func CreateZendeskTicket(title, body, email string) error {
ticket := ZendeskTicket{
Ticket: Ticket{
Comment: Comment{
Body: body,
},
Priority: "normal",
Subject: title,
Requester: Requester{
Email: email,
},
},
}
payload, err := json.Marshal(ticket)
if err != nil {
return err
}
url, _ := url.JoinPath(configs.CONFIG.Zendesk.BaseURL, "api/v2/tickets.json")
req, err := http.NewRequest("POST", url, bytes.NewBuffer(payload))
if err != nil {
return err
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Basic "+configs.CONFIG.Zendesk.APIKey)
client := &http.Client{}
res, err := client.Do(req)
if err != nil {
return err
}
defer res.Body.Close()
if res.StatusCode != 201 {
return errors.New("Failed to create ticket: " + res.Status)
}
return nil
}
1条答案
按热度按时间ggazkfy81#
我终于找到了做这件事的方法。
1.创建一个标记并更新触发条件,使其不会触发发送给Zendesk Jmeter 板上的请求者的任何电子邮件
1.触发时在代码上添加标签。