We have provided also a sample Python script to download multiple attachments that you can use as a guide to develop similar functionality in your preferred language.
The steps below are executed using Postman, but can be executed using any tool capable of executing API calls.
You can return both, a list of cases and any other exact information about them at the same time using the
search command as described in the FogBugz API: Listing, Searching and Viewing Cases article.
Retrieving Case Comments
- Get a token, either using the API, or using the Web UI.
- To search for a case or cases, use search API command, also passing the token retrieved and the previous step. For instance, to retrieve the metadata of case #24, use the following call body:
<Enter token from step 1>",
Note: Alternatively you can also use a GET request, for eg:
- Comments are listed in the results under the element (aka column)
s, as indicated below for this example:
- Compare the comment or comments with FogBugz UI, as seen below:
- Execute the steps listed under Retrieving case comments to get the case events.
- If you have an attachment, it will be presented under the
rgAttachmentsproperty of the event where it was attached, as seen below for this example:
Create the direct link to the attachment by
Using your instance URL
Add the content of the
sURLvalue after you replace in it each “&” string with the “&” sign
Add your token to the end of the URL
Note: The token at the end of the full URL is important, otherwise the attachment download will silently fail.
- Repeat the procedure above for all cases to retrieve all the comments or attachments you need.
Python Script to Download Multiple Attachments
The Python script attached to this article
downloadAttachments.py can assist you in the process of retrieving attachments automatically.
Note: This script is offered only as a guide to develop similar functionality in your preferred language. Our Support Team should not be contacted with customization requests for this script.
To use the script, follow the steps below:
- Ensure you have the latest Python installed (the script was tested with v3.10.2). Python can be downloaded from python.org for any operating system. How to use Python on Windows or Linux is also documented on docs.python.org
Note: the script uses the following Python modules (you might need to install them using pip):
- requests (eg:
python -m pip install requests)
- requests (eg:
- Retrieve an API token from a user with Administrator rights.
- Create and save a filter with all of the cases in your instance.
Note: Filters can list a maximum of 100.000 results. So if you have more than that, you will need to run the script 100 thousand cases at a time. The pagination can be done by using several saved filters.
- Access the filter and take note of the filter ID, which is the number in the URL after
- Edit the information below in the attached script
- line 6: substitute <your-API-token> for your API token from step 2.
- line 9: substitute <your-subdomain> for your domain. It's the part before the "
.fogbugz.com" in your URL (less the
- line 12: substitute 11 for the id of your saved filter from step 3.
Once that is done, save the Python script and run it in an empty directory (eg:
python downloadAttachments.py). The script will concatenate the case number to the attachment filename and download it. The end result will be as below: