JIRA API components name is not valid - python

I am currently attempting to create an issue within JIRA via API and have been running across an issue that I have no clue to fix.
I used a curl command to find the components and I got the following:
"components":[{"self":"https://jira-server/rest/api/2/component/18458","id":"18458","name":"JIRA","description":"#"},{"self":"https://jira-server/rest/api/2/component/18463","id":"18463","name":"JIRA"}]
when I run my script by using python-JIRA API with the following command:
new_issue = jira.create_issue(project='IT', summary='New issue from jira-python', description='look here', issuetype={'name': 'Task'}, components = [{'name': "JIRA"}])
I get the following error message:
response text = {"errorMessages":[],"errors":{"components":"Component name 'JIRA' is not valid"}}
Can anyone tell me what exactly I am doing wrong? I am 100% "JIRA" is a component since I manually created a test issue and selected "JIRA" as a component.

You have to make sure the Component you're linking to belongs to the same Jira Project that your issue is being created under

I believe your issue might be that you have too many brackets, components = [{'name': "JIRA"}] should be components = {'name': "JIRA"}
This is what I think your error is trying to tell you too when it says "errorMessages":[]....., the api only expects one set of brackets and passing it a set with information enclosed in another pair sets it off.
However I have not tried this solution but I do know it works when using issuetype = {'name' : 'Bug'}
Alternatively you probably don't even need the components part, it should create the issue with the other items given, if it doesn't its probably another field that only task requires. If you try to create an epic you need customfield_10814 to be filled with a description and for bug you need to fill the found at location.

The syntax is correct. components should be a list.
Did you create 'JIRA' as a component in the same project?
Make sure the component name is available for that project. If you go to any ticket in the same project, the 'dropdown' in the component section should list all the available components.

Create a component for 'JIRA' . From error it seems you project doesn't have any value called 'JIRA' .
Creation of value 'JIRA' for component will solve the problem

Related

Python Product Tag Update using Shopify API - 400 Error - Product :Required Parameter Missing Or Invalid

Just built my first Shopify store and wanted to use python and API to bulk-update product tags on all our products.
However, I've run into a snag on my PUT call. I keep getting a 400 Response with the message '{"errors":{"product":"Required parameter missing or invalid"}}'.
I've seen other people with similar issues on here but none of their solutions seem to be working for me.
Has anyone else run into this problem that can help me figure it out?
Here are some screenshots of my code, a printout of the payload, and the error in the response.
Code, Payload and Response:
I can successfully get the product info using the API and was originally sending the entire JSON payload that was returned just updated it with my product tags and sent it back through the API.
To narrow potential pain points, I'm keeping it simple now and just including "id" and "tags" in the payload but still get the same error.
We figured it out! It turns out that when we initially created the store we used a domain store name that was misspelled so we created a new domain store name with the correct spelling. However, the original domain store name was not deleted (not even sure it can be), and even though the new domain store name forwards to the original one and allows for GET requests, for PUT requests we had to use the original misspelled domain store name and the PUTs work fine.
I figured this out by using fiddler to capture a manual product update via the Shopify website to see what the payload looked like and that's why I noticed the store URL was different than the one we were using.
Hope this helps someone with a similar issue!

Initializing Repo Object With Git Package in Python

I have been working for days on how to check if a file is in a specific directory, and I narrowed the question down the following: initialize a repo object with the git package in python?
I have looked elsewhere and have found the following code: git.Repo.init(self.repo_path). But what is repo_path? How do you grab it? Alternatively, some people use os.path.exists(filePathAndName), but this still does not help. How do you get the filePathAndName? And does this solution assume that your github is downloaded to your desktop?
In essence, the code on the internet seems to lack context, but I am sure I am missing something. Any help would be very much appreciated.
repo_path is the name of the variable, whose value is the path to the repo/directory. You took this part out of its context, where self.repo_path is surely defined. The same goes for filePathAndName.
Using Git, based on the description of your problem, seems irrelevant. And it lead you to an XY problem : "how to initialize a git repo" instead of your actual problem "how to check if file exists".
You seem to lack programming knowledge, notably how variables work. Here is a tutorial about them.
In short, you can associate values to certain names. For example :
filePathAndName = 'path/to/file.txt' # storing the value inside the variable
os.path.exists(filePathAndName) # using the variable as parameter to a function call
which is basically the same as :
os.path.exists('path/to/file.txt') # using the value directly for the function
and is a correct way to get your answer.
If you meant to check if a certain file exists in a Git repository, it is a bit more difficult because the file could exist in a different branch, currently not existing on your filesystem. So a Git library may be of use there to get this info.
Here is an example based on the GitPython's tutorial :
# having installed the library "GitPython" beforehand
from git import Repo
path_to_my_file = 'path/to/repo/somewhere/inside/there/is/file.txt'
path_to_my_repo = 'path/to/repo'
my_repo = Repo(path_to_my_repo)
# iterate over the repo's branches to check if they contain your file
I hope this clarifies the subject we are talking about.

Is it possible to add a member to a distribution (mailing) list with Python?

I'm using Microsoft Azure and more specifically Active Directory. I'm currently using Python and the Graph REST API to create users. I would also like to add them to a mailing list in Exchange but by searching through the docs for hours and looking at various SO post it seems it's not supported. So I'm now looking at different Python libraries to possibly achieve that and haven't really found an answer.
Could someone please bring some light to this issue and perhaps show an example? All I'd like to do is to somehow programmatically and using Python add a member to a mailing list. Thank you in advance.
It seems that there is not an official MS Graph SDK for Python.
You can refer to the Python sample here.
For this application, you will use the Requests-OAuthlib library to make calls to Microsoft Graph.
This sample is to get the events in O365.
def get_calendar_events(token):
graph_client = OAuth2Session(token=token)
# Configure query parameters to
# modify the results
query_params = {
'$select': 'subject,organizer,start,end',
'$orderby': 'createdDateTime DESC'
}
# Send GET to /me/events
events = graph_client.get('{0}/me/events'.format(graph_url), params=query_params)
# Return the JSON result
return events.json()
What you need to modify is to call Add a member to a group

Problems flagging/unflagging JIRA issues using jira-python

I use the Python JIRA API wrapper almost daily to log time, add comments, and transition issues. Recently my team decided to replace the "Roadblock" status with an "Impediment" flag. My issue is that I cannot flag/unflag an issue from within an issue (https://jira.atlassian.com/browse/JSWSERVER-16346).
The following code to update customfield_10500 (the flag) does not work:
jira = JIRA(options=options, basic_auth=(os.getenv('user'), os.getenv('pass')))
i = jira.issue('BIS-9')
i.update(fields={
'customfield_10500' : {'value' : 'Impediment'}
})
The error
JIRAError: JiraError HTTP 400 url
response text = {"errorMessages":[],"errors":{"customfield_10500":"Field 'customfield_10500' cannot be set. It is not on the appropriate screen, or unknown."}}
I know the field must be set within the Kanban board, but I don't know how to do this using the Python wrapper.
Is there a way to do this?
I've found this but don't know how to translate it.
If you want to update a customfield through RestApi the customfield should be added into the Edit Mode Screen.
I believe this is why it is showing the above error

Telescope and not Working with Embedly

I have set up a telescope project and want to use embedly to get thumbnails. I am running on localhost.
I got an API key from embedly, placed the key into the telescope settings, and ran the Meteor.call('fetchFeeds') to pull info info. from RSS feeds.
The articles load fine and are posted but I am getting errors of:
I20150827-18:02:31.030(-5)? Couldn't find an Embedly API key! Please add it to your Telescope
enter code here settings or remove the Embedly module.
and no thumbnails show up.
I have tired reinstalling telescope, reinstalling module from embedly, and I checked in embedly and I do not have any API requests so I know it is something in telescope. I doubled check API key and generated new one tried that one too.
Can anyone help? I'm at a loss for what's happening.
You need to provide a width and height otherwise the error shows up as not providing an API key.

Categories

Resources