Python script to download all attachments?

Python script to download all attachments?

Hi, does anyone have a script that lets a user download all of the attachments on a ticket?

We have quite a few tickets with 5-10 attachments, and it's quite labourious for a user to download each one.

qty = 0
for Attachment in AttachmentList:
    Name = AttachmentList[qty]['name']
    Download = URL+AttachmentList[qty]['content_url']
    GetDownload = requests.get(Download, headers={'authtoken':KEY, 'accept':'application/vnd.manageengine.sdp.v3+json'}, verify=False)
    open(Name, "wb").write(GetDownload.content)
    qty += 1

I've got something written to this point, but when I invoke it in a Custom Menu, it downloads all the attachments on the server, rather than on the user's PC.

With that being the case, I don't think this is something I'll be able to accomplish running a Python script, and might need a Custom Function to run instead.
      • Topic Participants

      • AJ

                  New to ADSelfService Plus?