API & Macros - Can't add attachments

3 Comentários

  • Christopher Kennedy
    Zendesk Developer Advocacy
    Hi Nutripath IT Team,
     
    Are you creating macro attachments specifically?  This must be done with our Create Macro Attachment endpoint rather than our Uploads endpoint for ticket attachments.
    0
  • Nutripath IT Administration

    Thanks Chris, I can see where I went wrong there. I am now trying to upload and attach a file to a macro as per the 'Create Macro Attachment' section in the API doc, but this is failing - both in Postmane and via Powershell.

    In Postman I've got the 'attachment' field working fine, but still getting a 400 bad request for the file name field:

     

    In my Powershell script I am still trying to work out how to write the invoke-webrequest command, but seeing this (code below):

    $newFN = "C:\Users\BrettF\Desktop\20230203121449.jpg"
    $Fields = @{'attachment' = $newFN; 'filename' = '20230203121449.jpg'}
     

    Invoke-WebRequest -Uri 'https://nutripath.zendesk.com/api/v2/macros/redacted/attachments.json' -Headers @{'Authorization' = 'Basic [redacted]'} -Method 'POST' -ContentType 'multipart/form-data' -Body $Fields
    0
  • Christopher Kennedy
    Zendesk Developer Advocacy
    No problem.  I did some testing and I can replicate this in cases where the macro does not add a comment.  Since the attachment would be used in the comment added by the macro, a comment must be present in the macro actions to add the attachment.  Does the error still persist when adding an attachment to a macro that adds a comment?
    0

Por favor, entrar para comentar.

Powered by Zendesk