Working with Attachments using Jama Connect® REST API

Amanda Jennewein
Amanda Jennewein
  • Updated

Updated: October 2024

Audience: Jama Connect® Administrators 

Products Applicable: Jama Connect®

What are Attachments? 

Jama is designed to allow for great content flexibility, making it the ultimate definition of a system of record. While many of our customers are busy tapping away at the keyboard, they often associate their content with documents, images, graphs, tables, equations, and more. External documents and images are referred to as attachments in Jama.

Uploading Attachments via REST API

There are two main ways to utilize attachments in Jama:

  1. Attach a file to an item
  2. Embed a clickable link to an attachment within an item's text

Adding an Attachment to a Jama Item

Attachments can be uploaded through our REST API and associated with an item in three quick steps:

Step 1: Create an Attachment Item

Attachment items contain the metadata for an attachment. The JSON payload can define a name, description, and other fields associated with the attachment's item type.

This is precisely like filling out the name and description when an attachment is created in the UI:

Screenshot 2024-07-08 at 11.33.29 AM.png

Note: Name is the default required field in the attachment item type.

POST the attachment Item using the following endpoint:

Screenshot 2024-07-08 at 11.34.06 AM.png

You should receive a response confirming the attachment was created. Use the location to determine the ID of the newly created attachment item:

Screenshot 2024-07-08 at 11.34.30 AM.png

You have successfully created an attachment item!

Step 2: Upload the Attachment File

Files can be uploaded to Jama using a PUT with form data to the following endpoint:

Screenshot 2024-07-08 at 11.35.22 AM.png

The attachmentID is the ID retrieved from the response location in step #1 above. If you receive a 200/201 response status from the server, you have successfully uploaded a file to the Jama attachment!

Step 3: Associate the Attachment with an Item

To associate an attachment item with a Jama item, the attachment widget must be enabled on the Jama item’s item type before establishing an association.

Attachments can be associated with items that contain a POST method for an attachment. The attachment item ID is required in all cases. The following attachment endpoints are available:

Screenshot 2024-07-08 at 11.36.11 AM.png

The JSON payload should contain the attachment item ID:

Screenshot 2024-07-08 at 11.36.29 AM.png

You should receive a response indicating the status of your POST as shown below:

Screenshot 2024-07-08 at 11.37.00 AM.png

The final result should appear in the attachment widget section of the object in Jama like this:

Screenshot 2024-07-08 at 11.37.19 AM.png

You have successfully associated an attachment with a Jama item using the REST API!

 

Embedding a Link to an Attachment in a Jama Object

Embedding clickable hyperlinks for attachments within content is also possible through our REST API. These appear in Rich Text fields as clickable links that can be used to download attachments.

Once an attachment item is created and the attachment’s file is uploaded (steps #1 and 2 from the approach above), there are three steps to creating a clickable link to the attachment:

Step 1: Get the Attachment's Attachment Value and File Name

Once an attachment is created in Jama and its file has been uploaded, GET the attachment item using the following endpoint:

Screenshot 2024-07-08 at 11.38.55 AM.png

Retrieve the attachment value from the fields section, as well as the attachment’s fileName (highlighted below):

Screenshot 2024-07-08 at 11.39.50 AM.png

Note: the attachment value is not the attachment item’s ID but the attachment value stored in the fields section of an attachment object.

Step 2: Create a Hyperlink to your Attachment Item

Create a string with the following form:

Screenshot 2024-07-08 at 11.41.07 AM.png

Step 3: Update Jama Item's Rich Text Field

The string from step #2 now needs to be inserted into a Rich Text field of an Item to be accessible via the UI. Any endpoint that creates or updates a Jama Item's content can be used to update/generate an item with the clickable link embedded in a Rich Text field. Below are a few available endpoints:

Screenshot 2024-07-08 at 11.42.08 AM.png 

A clickable link should now appear in the object’s Rich Text field as shown below:

Screenshot 2024-07-08 at 11.42.34 AM.png

Clicking on the hyperlink text should result in the attachment being downloaded: 

Screenshot 2024-07-08 at 11.42.49 AM.png

You have successfully embedded a link to your Jama attachment item!

Downloading Linked Attachments

An attachment file can be downloaded using the previously created attachment link in three steps: 

Step 1: Retrieve the Attachment Link

Retrieve the object containing an embedded attachment link. Below are a few available endpoints:

Screenshot 2024-07-08 at 11.43.51 AM.png

Step 2: Parse out the Attachment Link

Parse out the embedded attachment link from the content of the retrieved object’s Rich Text field. Parsing libraries such as JSOUP for Java and BeautifulSoup for Python are helpful for this step.

Step 3: Download the Attachment file

Download the file using the following endpoint:

Screenshot 2024-07-08 at 11.45.09 AM.png

The request payload should contain the link URL that was parsed out in step #2 and will look like this:

Screenshot 2024-07-08 at 11.45.27 AM.png

If a response status of 200/201 is received, you've successfully downloaded your attachment file to your working directory. 

 

Need Help Getting Started?

  • If you need help uploading and downloading attachment files from Jama, check out our starter scripts, which are available on GitHub.

Please feel free to leave feedback in the comments below.

Related to

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.