0

从 zendesk 的代理视图中,我想注入代码来更新 zendesk 票证,但我不确定在没有身份验证的情况下是否可行?现在我正在尝试这个但得到一个“禁止响应”

不确定是否有人对此有所了解?

"request": {
    "comment": {
        "body": "Submitting a test comment"
    }
}
});
var apiURL = 'https://[subdomain].zendesk.com/api/v2/requests/[id].json';
$.ajax({
    url: "/api/v2/requests/" + id+ ".json",
     type: 'PUT',
     data: JSON.stringify(request),
     contentType: "application/json",
     success: function(data, textStatus, jqXHR) {
         alert("Success")
     },
     error: function(XMLHttpRequest, textStatus, errorThrown) {
         alert(errorThrown);
     }
});
4

1 回答 1

0

能够使用它来解决这个问题。

"request": {
    "comment": {
        "body": "Submitting a test comment"
    }
}
});
var token = document.getElementsByName("csrf-token")[0].content;
var apiURL = 'https://[subdomain].zendesk.com/api/v2/requests/[id].json';
$.ajax({
    url: "/api/v2/requests/" + id+ ".json",
     type: 'PUT',
     data: JSON.stringify(request),
     contentType: "application/json",
     headers: {
         "X-CSRF-Token": token
     }
     success: function(data, textStatus, jqXHR) {
         alert("Success")
     },
     error: function(XMLHttpRequest, textStatus, errorThrown) {
         alert(errorThrown);
     }
});
于 2017-05-24T00:14:47.130 回答