curlでたたくと参考ページにあるこれでできそう
(参考ページ:Create ticket comment)
ターミナルcurl https://{subdomain}.zendesk.com/api/v2/tickets/{id}.json \
-d '{"ticket": {"comment": { "body": "The smoke is very colorful.", "author_id": 494820284 }}}' \
-H "Content-Type: application/json" \
-v -u {email_address}:{password} -X PUT
|
これを Google Apps Script でやってみよう
コード.gs
var END_POINT = "https://NAME.zendesk.com/api/v2/";
function putTicketById() {
var zendeskId = 2;
var url = END_POINT + 'tickets/' + zendeskId + '.json';
var options = getOptions();
UrlFetchApp.fetch(url, options);
}
function getPayload() {
var payload = {
"ticket": {
"comment": {
"body": "add internal comment",
"public": false//Internal noteにしたい場合はfalse
}
}
}
var json = JSON.stringify(payload);
return json;
}
function getOptions() {
var options = {
"method": "put",
"contentType": "application/json",
"headers": getHeaders(),
"payload": getPayload()
}
return options;
}
function getHeaders() {
var headers = {
"Authorization": "Basic " + getZendeskToken()
}
return headers;
}
function getZendeskToken() {
return PropertiesService.getScriptProperties().getProperty('zendesk_token');
}
|
実行前に
END_POINTとzendeskIdを対象のものに変更します。
var END_POINT = "https://NAME.zendesk.com/api/v2/";
の NAME を自分のzendeskの名前に変更して
var zendeskId = 2;
は対象のzendeskのチケット id に変更して
putTicketById() を実行します
実行結果
参考
Create ticket comment
https://developer.zendesk.com/rest_api/docs/support/ticket_comments#create-ticket-comment
