Add Attachments from a Node to an Issue

Use this endpoint to add any attachments from a question, answer, or comment added after the question was submitted to JIRA as an issue/ticket.

/services/v2/jira/node/[node-id]/issue/[issue-id]/attachments.json

🚧

Permissions & Notes:

Make sure you have read the JIRA Integration Documentation in the Get Started, Integrations and Plugins Section before trying out the endpoint. There are specific steps and permissions needed to be able to see results from the endpoints in your AnswerHub instance.

Sample Request

A POST Attachments from a Node to an Issue request to add attachments from a specific comment node (node=873) to a specific issue/ticket in JIRA (ID=69314) to https://apidocs.cloud.answerhub.com using a human-readable Username/Password (answerhub/test123) would look like the following cURL request below:

📘

NOTE:

You can extract the issue-id/jira-id (they are the same), from the following GET endpoints responses:

  • /services/v2/jira/node//ticket.json

  • /services/v2/jira/key//ticket.json

In the example request below, the user demo4 commented (ID:873) on the question (ID:872) and included an attachment you want to add to the ticket in JIRA. To add the attachment, you will need to make a request to retrieve ticket info by Jira key to obtain the issue-id, which the system will label as jira-id in the response and you will need to obtain the comment node id.

curl 
 -u user:password 
 -H "Accept: application/json" 
 -H "Content-type: application/json" 
 -X POST "https://apidocs.cloud.answerhub.com/services/v2/jira/node/873/issue/69314/attachments.json"

Expected Response: HTTP 200 - OK

[
    {
        "self": "https://yourcompanynamehere.atlassian.net/rest/api/2/attachment/60107",
        "id": "60107",
        "filename": "user-interface-expertise-doc-screenshot-2019-02-21.png",
        "author": {
            "self": "https://yourcompanynamehere.atlassian.net/rest/api/2/user?accountId=5b087cccc83b765e4c37d5f1",
            "name": "JIRAadminusername",
            "key": "JIRAadminusername",
            "accountId": "5b087cccc83b765e4c37d5f1",
            "emailAddress": "[email protected]",
            "avatarUrls": {
                "48x48": "https://avatar-cdn.atlassian.com/4e955c70eeff0abe1974c9be300a8887?s=48&d=https%3A%2F%2Fyourcompanynamehere.atlassian.net%2Fsecure%2Fuseravatar%3FavatarId%3D10122%26noRedirect%3Dtrue",
                "24x24": "https://avatar-cdn.atlassian.com/4e955c70eeff0abe1974c9be300a8887?s=24&d=https%3A%2F%2Fyourcompanynamehere.atlassian.net%2Fsecure%2Fuseravatar%3Fsize%3Dsmall%26avatarId%3D10122%26noRedirect%3Dtrue",
                "16x16": "https://avatar-cdn.atlassian.com/4e955c70eeff0abe1974c9be300a8887?s=16&d=https%3A%2F%2Fdyourcompanynamehere.atlassian.net%2Fsecure%2Fuseravatar%3Fsize%3Dxsmall%26avatarId%3D10122%26noRedirect%3Dtrue",
                "32x32": "https://avatar-cdn.atlassian.com/4e955c70eeff0abe1974c9be300a8887?s=32&d=https%3A%2F%2Fyourcompanynamehere.atlassian.net%2Fsecure%2Fuseravatar%3Fsize%3Dmedium%26avatarId%3D10122%26noRedirect%3Dtrue"
            },
            "displayName": "[email protected]",
            "active": true,
            "timeZone": "America/New_York"
        },
        "created": "2019-02-21T11:18:27.027-0500",
        "size": 284573,
        "mimeType": "image/png",
        "content": "https://yourcompanynamehere.atlassian.net/secure/attachment/60107/user-interface-expertise-doc-screenshot-2019-02-21.png",
        "thumbnail": "https://yourcompanynamehere.atlassian.net/secure/thumbnail/60107/user-interface-expertise-doc-screenshot-2019-02-21.png"
    }
]

Community User Interface Result

You can see the question and comment here and the JIRA status in the right side panel

Request Sample Without Having the Permission to Attach a File

curl 
-u answerhub:test123 
-H "Accept: application/json" 
-H "Content-type: application/json" 
-X POST "https://apidocs.cloud.answerhub.com/services/v2/jira/node/873/issue/69314/attachments.json"

Expected Response: HTTP 403 - Forbidden

{
"error":"Attachments is disabled or you don't have permission to add attachments to this issue."
}
Language
Authentication
Basic
base64
:
Click Try It! to start a request and see the response here!