Using the REST Post Snap to add attachments to Jira Issues

In this example, we use a REST Post Snap to add attachments to a Jira issue.

You design the pipeline as shown below. This pipeline contains the following Snaps:
Rest Post pipeline overview
Download this Pipeline
  • Creating the Jira Ticket
    • File Reader: Reads a file containing the details required to create a ticket in Jira.
    • JSON Parser: Structures the data received from the File Reader Snap as a JSON document.
    • Mapper: Creates a document containing the data needed to create a Jira ticket, by extracting and mapping data from the incoming document.
    • JIRA Create: Creates a Jira ticket using the details provided by the Mapper Snap.
  • Updating the Jira Ticket
    • Mapper: Creates a document containing the key associated with the record that you want to update.
    • REST Post: Updates the ticket with the specified attachments.

You configure these Snaps as explained in the sections below:

  1. Configure the File Reader Snap to read a JSON file from the SnapLogic File System:

    File Reader Snap configuration

    Once the pipeline is validated, you can view the output of the File Reader:


    File Reader output preview
  2. Configure the JSON Parser Snap to read the structure of the JSON file:

    JSON Parser configuration

    Once the pipeline validates successfully, you can view the output of the JSON Parser Snap:


    JSON Parser output preview
  3. Configure the Mapper Snap to map fields for Jira ticket creation

    You now need to add the details required to specify where the ticket must be created, and to whom it must be assigned. You do this using the Mapper Snap. The Mapper Snap maps the schema of the source document (the JSON Parser Snap's output) with the schema of the target document (the schema of a Jira ticket as propagated backward by the JIRA Create Snap).


    Mapper Snap configuration

    Once fields from the input document are mapped to fields in the Jira ticket schema and the Pipeline is validated, you can view a preview of the output:


    Mapper output preview
  4. Use the JIRA Create Snap to create the Jira ticket

    You now have a document containing all the details that you need to create a Jira ticket, and you use the JIRA Create Snap to create the ticket:


    JIRA Create Snap configuration

    Once the ticket is created successfully, you can view the output in the preview:


    JIRA Create output preview
  5. Configure the Mapper Snap to isolate the Jira ticket ID

    You just created a Jira ticket, and you can see the ticket ID displayed against the $key field in the output preview of the JIRA Create Snap. You can now add attachments to this ticket. You decide to add two images. To do so, you use the Mapper and REST Post Snaps.

    Configure the Mapper Snap to isolate the Jira ticket number from the output of the JIRA Create Snap:


    Mapper Snap isolating Jira key

    Once you validate the pipeline with your latest changes, you can see the output preview of the Mapper Snap, and you can see that only the ticket ID is retained:


    Mapper Snap output showing Jira key
  6. Configure the REST Post Snap to upload attachments

    You configure the REST Post Snap to upload two images as attachments to the identified Jira ticket, accessible through a Service URL:


    REST Post Snap configuration for uploading attachments

    For a successful upload, the REST Post Snap displays a status code of 200:


    REST Post Snap successful response

You have now successfully created a Jira ticket and added attachments to the ticket.