API Add Attachments

API Add Attachments

Hello everyone,

I try to add attachment to request. As you can see on attachment i can upload from PostMan. I made a simple form for upload attachment to request but it gave an error like below.

  1. {"response_status":{"messages":[{"type":"failed","message":"The value given for the [request] fields is invalid","status_code":"4001"}],"status":"failed"}}
I guess input name is wrong but i couldn't figure it out.
  1. <form id="form" name="form" method="post" enctype="multipart/form-data" action="javascript:void(0);">
  2.     <input id="file" name="file" type="file" />
  3.     <button class="upload">Upload</button>
  4. </form>

  5. <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  6. <script>
  7. $(document).ready(function() {

  8.     $(document).on("click", ".upload", function()
  9.     {
  10.         $.ajax({
  11.             type:"POST",
  12.             url:"http://10.10.10.10:8080/api/v3/attachments?input_data=%7B%22attachment%22%3A%7B%22request%22%3A%7B%22id%22%3A%2228185%22%7D%7D%7D&TECHNICIAN_KEY=xxxxx",
  13.             dataType:"text",
  14.             cache: false,
  15.             contentType: false,
  16.             mimeType: "multipart/form-data",
  17.             processData: false,
  18.             data:$("#form").serialize(),
  19.         })
  20.         .done(function(response) {
  21.             alert(response);
  22.         });

  23.         return false;
  24.     });
  25. });
  26. </script>

                New to ADManager Plus?

                  New to ADSelfService Plus?