Can I attach files to Samange API call?

Hello THWACK community,

I am making a Samanage API call that creates an incident. It works fine, but I was wondering is it possible to add files to the API call so the attachments are viewed on the ticket itself. Right now, the API call would create a ticket and then I would manually attach a file on Samanage. I would much rather have a one step process then this two step one.

Thank you.

  • Edit: See the follow up comment below for the correct process for adding attachments.

    After some investigation it looks like this should be possible, they just haven't included documentation on how to attach the file to an incident.

    However, it looks like the steps should be the following:

    1. Create an attachment using the endpoint "/attachments" (see documentation here: https://apidoc.samanage.com/#operation/createAttachment )

    2. Store the response, and get the attachment UUID from the response object. The response object should look something like:

    {
        "file": {
            "attachable_type": "Incident",
            "attachment_content_type": "text/plain",
            "attachment_file_name": "SWSD Test Attachment.txt",
            "attachment_file_size": 0,
            "attachment_type": "attachment",
            "attachment_updated_at": "2021-08-09T19:54:58.772Z",
            "uuid": "ID REDACTED",
        }
    }

    You'll want to pull the UUID attribute.

    3. Create the incident, and add the attachment_uuids field to the incident json:

    {
        "incident": {
            "assignee": {
                "email": "example@email.com",
            },
            "requester": {
                "email": "example@email.com",
            },
            "attachment_uuids": ["UUID STRING HERE"],
            "name": "Incident Title",
        },
    }

    I haven't tested this yet, but it should work based on seeing how they handle it on the website. If you use the inspect element tool in Chrome, Edge, or Firefox you can create an incident with an attachment and see the same behavior. Basically, the attachment gets created, then when the Incident is created, it's associated with the previously created attachment.

    Since this is undocumented, there's no guarantee that this will continue to be supported. Use at your own risk.

    If for some reason this doesn't work, let me know and I will look into it further.

  • Also, see this related question from who was able to confirm what the request body needs to be for incidents and comments:

    https://thwack.solarwinds.com/product-forums/solarwinds-service-desk-swsd/f/forum/91802/api---sample-add-attachment-via-powershell

  • To send an attachment, your request must have a payload. ... Cached attachments are stored in the project, so you can remove the original file.

    Thank You........

    mybpcreditcard