Work with Attachments using APIs
In Targetprocess, attached files and uploads are stored in the form of Attachment resources. In order to automate attachments management, you can use CRUD (create / read / update / delete) methods supported by our APIs.
Get list of all Attachments
REST API allows to get the list of all Attachment files that currently exist in the system. Every list element contains the URI’s to the Attachment resources (Uri property) and references to a general entities (for example, User Story, Bug, Task, Feature, Release, etc.) in General property.
The endpoint for a REST service will be:
You get the list of nodes. Each node represents the single file in the system. Format is the following:
<Attachment Id="1234" Name="NewAccountScreen.xls">
<Description>Form for new Account creation.</Description>
<Owner ResourceType="GeneralUser" Id="23">
<General ResourceType="General" Id="1884" Name="Create Account Service"/>
See the definition of available fields at https://md5.tpondemand.com/api/v1/Attachments/meta.
If you work with an account hosted on our cloud servers, please always use https:// prefixes when you request a list of attachments. Otherwise you will get wrong URI's to the elements.
Sometimes you may face the large results set issue when not all Attachments are seen to be included in the response. You have to iterate over each General item and then make a second call that pulls the attachments URLs for that specific General item id. Use REST API pagination carefully as well.
Get list of all Attachments for an entity with known ID
You can use relevant Entity type here. Use our Resources model for the reference. Most common endpoints are:
Filtering and sorting Attachments list
These actions are not supported so far. You have to query for the list of all Attachments, parse, filter and sort them on client side and then look for required elements.
Download single Attachment file
For authentication, you can use basic authentication method or send a cookie that imitates web browser behavior.
HTTP GET request type should be used.
It is possible to generate basic authentication credentials that are not related to a specific Targetprocess user. Special account 'System' can be used for this purpose. It does not belong to any specific human user and we recommend to use this account for integrations.
Password for the System user should be set in advance by Targetprocess Administrator on Settings → General Settings Settings → System User Credentials panel.
Then, you encode the pair system:passwordofsystemuser as base64 encoded string and pass this parameter in the header of your request to the API.
It is required to set properly Accept and Cookie header fields of the HTTP GET request.
You can't use REST API Token to download attached file so far.
Download inline images
It was possible to paste images to file storage without converting them to Attachments. That happened when you pasted images from Description editor. In on-site solutions such storage method is still actual.
It's not possible download inline images via REST API. The links to such images are available for view and downloaded only to web browser client.
For our hosted solution we have switched the file storage process from inline files to the Attachment entities.
Still have a question?
We're here to help! Just contact our friendly support team