Attachment uploads



  • Jessie Schutz
    Zendesk team member

    Welcome to the Community, Meredith! Thanks for your patience on this. :)

    We're working on finding someone to help you with this. Stand by!

  • Becca
    Zendesk team member

    Hi Meredith- 

    Just to ensure we're on the same page, are you working with a Zendesk ZAF V2 app? If so, uploading attachments via an app can definitely be a bit tricky. As a result, I have spun up a super simple sample app that demonstrates one method to accomplish this. Here's the example code from the iframe.html. Feel free to give this a try but please know it is provided to demonstrate functionality and is not something we can assist with or troubleshoot issue being custom code. 

      <meta charset="utf-8">
      <!-- -->
      <link rel="stylesheet" href="" type="text/css">
      <h2>File Upload Test</h2>
      <label for="data">Select file:</label>
      <input type="file" name="data[]" id="data" multiple>
      <button type="button" onclick="doit()">Upload file now...</button>
      <label>Token value:</label>
      <input type="text" id='token_value_from_upload' style="width: 220px;">
      <button type="button" onclick="doattach()">Attach file to ticket...</button>
      <script type="text/javascript" src=""></script>
    <script src=""></script>

        // Initialise the Zendesk JavaScript API client
        var client = ZAFClient.init();
        client.invoke('resize', { width: '100%', height: '100%' });

        // upload selected file
        function doit() {
          //retrieve the uploaded file
          var file = data.files[0];

            url: "" +,
            type: 'POST',
            data: file,
            dataType: 'json',
            processData: false,
            contentType: 'application/binary',
            headers: {
              "Authorization": "Bearer OAUTH_TOKEN"
            success: function(response) {
              document.getElementById('token_value_from_upload').value = response.upload.token;

        // attach uploaded file to ticket
        function doattach() {

          var ticket_update = '{"ticket": {"comment":  { "body": "New comment here", "uploads":  ["'
            + document.getElementById('token_value_from_upload').value + '"] }}}'


              var options = {
                url: "/api/v2/tickets/" + response_for_id[""].toString(),
                type: 'PUT',
                data: ticket_update,
                dataType: 'json',
                processData: false,
                contentType: 'application/json'

                function(response_to_update_ticket) {
                  console.log("Successful ticket update response here:", response_to_update_ticket);
                    console.log("Error ticket update response here:", error_updating_ticket);
  • Bryan - Community Manager
    Zendesk Developer Support

    See the Attaching files to tickets via API KB article for a slightly updated version of the above code sample.

    Also, for folks who might come across this, consider posting in the Zendesk Apps framework (ZAF) developer support community forum instead.


Post is closed for comments.

Powered by Zendesk