I tried to upload an attachment using add_attachment() python rest api, but getting error.
I am able to upload the same attachment from GUI but unable to retrieve the info using the issue.fields.attachment JIRA rest api.
Please suggest me the resolution for this.
Getting the below error while attaching the file:
=====================================
r.status_code, error, r.url, request=request, response=r, **kwargs)
jira.exceptions.JIRAError: JiraError HTTP 500
text: <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><title>Oops - an error has occurred</title><script type="text/javascript">contextPath = "";</script><link type='text/css' rel='stylesheet' href='/static-assets/metal-all.css' media='all'><script src='/static-assets/metal-all.js'></script><!--[if lt IE 9]><link type='text/css' rel='stylesheet' href='/static-assets/metal-all-ie.css' media='all'><script src='/static-assets/metal-all-ie.js'></script><![endif]--><!--[if IE 9]><link type='text/css' rel='stylesheet' href='/static-assets/metal-all-ie9.css' media='all'><![endif]--><meta name="decorator" content="none" /></head><body class=" error-page error500"><script type="text/javascript">document.body.className += " js-enabled";</script><div id="page"><header id="header" role="banner"></header><!-- #header --><section id="content" role="main"><div class="aui-page-panel"><div class="aui-page-panel-inner"><section class="aui-page-panel-content lowerContent"><div id="error-state"><span class="error-type"></span><h1>Sorry, we had some technical problems during your last operation.</h1><h2 class="technical-details-header"><span>Request assistance</span></h2><div id="technical-details-content" class="technical-details js-hidden"><p>Copy the content below and send it to your JIRA Administrator</p><div class="technical-details-content" contentEditable readonly><h2>Technical details</h2><p class="referral">Log's referral number: <strong>5bad8a91-8e65-4c68-a2e2-d6fcacab7748</strong></p><div class="info-section" id="causePanel"><h2>Cause</h2><p>Referer URL: <b>Unknown</b></p><pre></pre><p>Internal Server Error</p></div></div></div><p>Return to the <a href="javascript:window.history.back()">previous page</a></p></div></section><!-- .aui-page-panel-content --></div><!-- .aui-page-panel-inner --></div><!-- .aui-page-panel --></section><!-- #content --><footer id="footer" role="contentinfo"><section class="footer-body">
====================================================================
Retrieval of attachment information throwing below error
=============================================
AttributeError: type object 'PropertyHolder' has no attribute 'attachment'
hi here you find the python script
If you find this answer useful, I would kindly ask you to like and share it so the same will be visible to others who might be facing the same issue you have inquired.Thank you for your understanding.
# =============== # greeting.txt # =============== hello, world # =============== # upload.attachment.py # =============== import requests import json # [JIRA-BASE-URL], i.e.: http://localhost:8080 # [ISSUE-ID], i.e.: ATT-1 url = '[JIRA-BASE-URL]/rest/api/2/issue/[ISSUE-ID]/attachments' headers = {"X-Atlassian-Token": "nocheck"} # please uncomment to attach external file files = {'file': open('greeting.txt', 'rb')}
...........................
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It looks like you have hit the wrong URL with your REST call. You shouldn't have had any of that html back, it implies you're landing on standard pages rather than the REST one.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.