Export ALL attachments.

Hi all!

I need to export our ticket data weekly to be compliant. 

With that export, i also do need to periodically download all the attachments.

Now i know this question was already asked once, but that answer isnt an answer, its a pointer that i cannot divert to an answer.

How (step by step) do i download all my attachments and in such a manner that its connected to the CSV export of the ticket data (so correct attachment to the correct ticket).

And why isnt there a download button to do so? (i guess more customers need to comply to have a full backup of their data)

Thanks to anyone who can answer :)

Parents Reply Children
  • Howdy  and  !

    To use the SolarWinds Service Desk API to retrieve all attachments from tickets, you need to make a series of API calls. The API calls will need to first list all tickets and then fetch attachments for each ticket. SolarWinds Service Desk API uses RESTful principles and provides endpoints to interact with different resources, including tickets and their attachments.

    Below, I'll provide a general outline on how to script these API calls, including a JSON example for the necessary GET request. Please note that you will need an API token to authenticate your requests.

    Step 1: Obtain an API Token

    First, you need to have an API token from SolarWinds Service Desk. To retrieve this, see our documentation page.

    Step 2: List All Tickets

    You'll start by fetching all tickets. The endpoint to get all tickets might look something like this:

    GET https://api.samanage.com/incidents.json Authorization: Bearer your_api_token

    This endpoint will return a list of tickets. You need to handle pagination to fetch all tickets if there are more tickets than fit in one page. Check the response headers for pagination links.

    Step 3: Fetch Attachments for Each Ticket

    For each ticket, use the ticket ID to fetch attachments. The endpoint for getting attachments from a ticket could look like this:

    GET api.samanage.com/.../attachments.json Authorization: Bearer your_api_token

    Replace {ticket_id} with the actual ID of the ticket.

    Step 4: Script Example

    You can automate this process using a script. Below is a Python script example that demonstrates these steps using the requests library. You will need Python installed and the requests library which you can install using pip install requests.

    import requests def get_api(url, headers): response = requests.get(url, headers=headers) if response.status_code == 200: return response.json() else: print("Failed to fetch data:", response.status_code, response.text) return None def main(): api_token = 'your_api_token' base_url = 'https://api.samanage.com' headers = { 'Authorization': f'Bearer {api_token}', 'Accept': 'application/json' } # Fetch all tickets tickets = get_api(f"{base_url}/incidents.json", headers) if tickets: for ticket in tickets: ticket_id = ticket['id'] # Fetch attachments for each ticket attachments = get_api(f"{base_url}/incidents/{ticket_id}/attachments.json", headers) if attachments: for attachment in attachments: print(f"Ticket ID {ticket_id} has attachment: {attachment['name']} URL: {attachment['url']}") if __name__ == "__main__": main()

    Step 5: Execute and Store

    Run the script to fetch all the attachments. You may need to modify the script to handle pagination fully or adjust fields according to your specific needs. Also, consider error handling and rate limiting compliance as per SolarWinds API guidelines.


    • Always secure your API token.
    • Adjust the API endpoints if there have been updates or changes in the SolarWinds Service Desk API.
    • Make sure to test the script in a development environment before running it in production.