The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

looking for a solution in downloading a Jira attachment

Adrian Jordan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 16, 2021

I was originally using Jenkins plugin (Jenkins JIRA Pipeline Steps) to integrate Jenkins with Jira.  Unfortunately, I am unable to successfully download the attachment(s) to my Jenkins worker node.  Debugging this further, I attempted to use curl to GET the attachment:  curl -L -O -k -u 'adrianj@ibm.com:<myToken' -X GET http://<myhost>/secure/attachment/3454761/test.txt. The file downloads, but the contents of the file is invalid and reference a 403 forbidden message:

 

<body id="jira" class="aui-layout aui-style-default page-type-message " data-version="8.13.9" >
    <div class="aui-page-panel" ><div class="aui-page-panel-inner">
            <main role="main" id="main" class="aui-page-panel-content" >
                    <div class="aui-page-header" ><div class="aui-page-header-inner">
                            <div class="aui-page-header-main" >
                                    <h1>Forbidden (403)</h1>
                                </div>
                        </div></div>
                    <div class="aui-message aui-message-warning warning">
                            <p>Encountered a <code>&quot;403 - Forbidden&quot;</code> error while loading this page.</p>
                            <p>Basic Auth with password is disabled by the API Token Authentication app</p>
                            <p><a href="/secure/MyJiraHome.jspa">Go to Jira home</a></p>
                        </div>
                </main>
        </div></div>
</body>

 

Are there in proven solutions in place to download Jira attachments?

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Nir Haimov
Community Champion
August 16, 2021

Hi @Adrian Jordan 

You got 403 and it says to you:

Basic Auth with password is disabled by the API Token Authentication app

Means you have authentication problem 

Adrian Jordan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 17, 2021

Thanks @Nir Haimov .  Yes I saw that, which has led me down the path of using cookies.  I have a solution in curl, by creating the cookie:

curl -c /path/to/some/folder/cookie-jar.txt -u username:apitoken https://<jira-url>/rest/api/2/issue/<issueIdOrKey>?fields=attachment

and then using it

curl -b /path/to/some/folder/cookie-jar.txt "https://<jira-url>/secure/attachment/10100/portallog.jpg" --output /path/to/some/folder/portallog.jpg

Source of reference:  https://wiki.resolution.de/doc/api-token-authentication/latest/user-guide/knowledge-base/using-api-tokens-to-download-attachments 

Nir Haimov
Community Champion
August 17, 2021

So all is good?

You managed to achieve your final goal? :)