Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Unable to retrieve and update the attachment information in Python-jira rest api

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&#39;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'

2 answers

0 votes

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.

hi here you find the python script 

how to upload attachment to an Issue using the REST API in Python

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')}

...........................

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Bitbucket Smart Commits vs. Genius Commits - What's the difference?

If you already heard about Smart Commits in Bitbucket, know that you just stumbled upon something even better (and smarter!): Genius Commits by Better DevOps Automation for Jira Data Center (+ Server...

106 views 0 2
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you