I'm trying to use JIRA python api to receive the list of tickets that have been raised in the last 30 days but whenever i run
Issue = main.jira.issue("PLAT-38592")
i = main.jira.issue(issue, "Summary")
print(i)
All that gets returned is
PLAT-38592
Then i try to poke at the issue
Issue = main.jira.issue("PLAT-38592")
print (Issue)
And all that gets returned is
PLAT-38592
I need to be able receive information from this ticket but it only returns a string
Issues are objects. You can access their content by accessing fields.
If you for example want to access the summary, you can use (according to the docs):
issue = jira.issue('PLAT-38592', fields='summary')
summary = issue.fields.summary
print(summary)
Related
I'm trying to use Tweepy (version 4.4.0) to get a user's description but it's seemingly not working:
u = api.get_user(username='XXXX', user_fields=['description'])
but the output of this is simply:
Response(data=<User id=123 name=XXX username=XXX>, includes={}, errors=[], meta={})
So it's getting me the name and id fine, but it's returning an empty for any user fields.
Note I've also tried with user_auth: 1, but I get 'Unauthorized: 401' - but from what I've seen around, I don't think user authentication is the problem here... but maybe it is?
Any advice would be great!
api seems to be an instance of tweepy.Client here.
From the relevant FAQ section in Tweepy's documentation:
Why am I not getting expansions or fields data with API v2 using Client?
If you are simply printing the objects and looking at that output, the string representations of API v2 models/objects only include the default attributes that are guaranteed to exist.
The objects themselves still include the relevant data, which you can access as attributes or by key, like a dictionary.
The user object being returned in the response should have a description field with the user's description.
You can access the description with: u.data.description
Keep in mind that the description may be blank some times, try with created_at to be sure it works.
Sample code for extracting description of any twitter user is as follows
import tweepy
auth = tweepy.OAuth2BearerHandler(os.environ.get("TWITTER_API_KEY"))
api = tweepy.API(auth)
user = api.get_user(screen_name="TechWiser", include_entities=False)
description = user._json['description']
user._json contain many other key, value pair that you can explore
I'm running pyxero and trying to get the reference and description from a bank transaction but am having trouble getting it.
I can run:
trans = xero.banktransactions.filter(BankAccount_Name="chosen_account")
Which gives me the transcations and details, however the reference and description are not present.
It also shows the LineItems are empty:
'LineItems': []
I also get the same if I try:
transaction = xero.banktransactions.filter(BankTransactionID=BankTransactionID)
Is there a way to get this information?
Many thanks
Need to use get instead of filter to get the LineItems:
transaction = xero.banktransactions.get(BankTransactionID)
To get all the lineitem detail you either need to :
retrieve a specific item by BankTransactionID (as #blountdj implies in their answer)
OR
use Xero API's built-in paging in the request by passing 'page=xxx' as an optional parameter (which you might need to loop through multiple pages/requests if >100 transactions - which is likely).
Refer Xero API reference re Bank Transaction paging here
I am trying to access the worklogs in python by using the jira python library. I am doing the following:
issues = jira.search_issues("key=MYTICKET-1")
print(issues[0].fields.worklogs)
issue = jira.search_issues("MYTICKET-1")
print(issue.fields.worklogs)
as described in the documentation, chapter 2.1.4. However, I get the following error (for both cases):
AttributeError: type object 'PropertyHolder' has no attribute 'worklogs'
Is there something I am doing wrong? Is the documentation outdated? How to access worklogs (or other fields, like comments etc)? And what is a PropertyHolder? How to access it (its not described in the documentation!)?
This is because it seems jira.JIRA.search_issues doesn't fetch all "builtin" fields, like worklog, by default (although documentation only uses vague term "fields - [...] Default is to include all fields"
- "all" out of what?).
You either have to use jira.JIRA.issue:
client = jira.JIRA(...)
issue = client.issue("MYTICKET-1")
or explicitly list fields which you want to fetch in jira.JIRA.search_issues:
client = jira.JIRA(...)
issue = client.search_issues("key=MYTICKET-1", fields=[..., 'worklog'])[0]
Also be aware that this way you will get at most 20 worklog items attached to your JIRA issue instance. If you need all of them you should use jira.JIRA.worklogs:
client = jira.JIRA(...)
issue = client.issue("MYTICKET-1")
worklog = issue.fields.worklog
all_worklogs = client.worklogs(issue) if worklog.total > 20 else worklog.worklogs
This question here is similar to yours and someone has posted a work around.
There is a also a similar question on Github in relation to attachments (not worklogs). The last answer in the comments has workaround that might assist.
Heres what I'm trying to do:
First of all, I want every entry in Account. After that, I want to use get on them to get the whole thing. However, I get an error message. I do the following:
accIdArr = sf.search("FIND {Account}")
print accIdArr
for i in accIdArr:
print i["Id"]
accDataArr = sf.Account.get(i["Id"])
print accDataArr
However, I get this error message:
simple_salesforce.api.SalesforceResourceNotFound: Resource Account Not Found. Response content: [{u'errorCode': u'NOT_FOUND', u'message': u'The requested resource does not exist'}]
I then tried to use sf.Account.get('CopyAndPastedId') with the Id that got printed before I get the error, eg i["Id"].
Well, that doesnt work either and gives the same error. So I thought about Account not existing, however sf.Account.metadata() works fine and gives the expected data.
What am I doing wrong?
Is there a reason to use SOSL rather than SOQL?
Since you are only requesting the Account Objects, a simple SOQL search will get you what you want. Try the following:
accDataDict = sf.query('SELECT ID, Name, <all other fields you want> FROM Account')
The return will be an ordered dictionary of all the Account Objects with the field/values you requested in your query.
How can I get the minutes spent from a worklog from an issue using the jira-python library?
Using the jirashell I see that the issue has the attribute issue.fields.worklog, however when I try to access that in my python code I get the error: AttributeError: type object 'PropertyHolder' has no attribute 'worklog'.
If I create a jira client and do jira_client.worklogs(ticket.key) in my python code, it returns a list of Worklogs and their ids but I don't know what to do with that. I see in the documentation there's a worklog() function that takes in the issue id, and the worklog id, but I don't understand what it returns and how I would use that/if it is what I'm looking for.
I found a roundabout way of doing it through the client.
As I iterate through each issue I get the list of worklogs per ticket by doing worklogs = jira_client.worklogs(issue.key) and then i iterate through all of the worklog items in the worklogs list (a nested for loop):
for worklog in worklogs:
totaltime += readtime(worklog.timeSpent)
Using the jirashell I accessed a specific worklog of a specific ticket: wl = jira_client.worklog(<issue key>, <worklog id>) then I typed in wl. and pressed TAB, it listed the following:
wl.author, wl.comment, wl.created, wl.delete, wl.find, wl.id, wl.raw, wl.self, wl.started,
wl.timeSpent, wl.timeSpentSeconds, wl.update, wl.updateAuthor, wl.updated
(Note: you need to include the period at the end of wl before pressing tab)
Running wl.timespent in the jirashell gave me gave me a unicode string with the number and then h or m for hour or minute (for example: u'6h'). Then I new that once I generated the worklog object in my loop above, I could access the time by using the timepsent attribute.
(Note: My readtime function turns the string into an integer and converts hours to minutes, and is not shown here)
The jirashell really helps with trying to find the attributes of the fields, etc. (Note: you need to install jira-python in addition to jira in order to run jirashell. Also if you installed jira-python in your virtualenv you need to run env/bin/jirashell from your command line once you are in your project's directory.)