I am using jira python to create issues through their REST api, but in the "fields" dictionary for the "project" key's dictionary, I am running into an issue when I try using "id" or "name" as keys, but it works with the "key" key.
So, this works:
'project': {'key': 'ORION'}
But, when I try using the other keys provided in the jira-python documentation such as:
'project': {'name': 'ORION-777'}
or
'project': {'id': 777}
or
'project': {'id': '777'}
It does not work. I am getting an error that says:
response text =
{
"errorMessages": [],
"errors": {
"project": "project is required"
}
}
I want to specify the id so that I don't keep creating issues for the same bug over and over. Any guidance is welcome. Thanks!
Following the documentation link that you provided, you can create an issue in the following ways:
new_issue = jira.create_issue(project='PROJ_key_or_id', summary='New issue from jira-python',
description='Look into this one', issuetype={'name': 'Bug'})
or
issue_dict = {
'project': {'id': 123},
'summary': 'New issue from jira-python',
'description': 'Look into this one',
'issuetype': {'name': 'Bug'},
}
new_issue = jira.create_issue(fields=issue_dict)
You can you a project key, name or ID.
To get the name or key, go the "Project settings" of your project then click on "Details" (you need to have the permission to see these settings).
To see the ID without making any rest query, go again in the "Project settings" page then mouse-over on details and you can view the project id in the navigation bar at the bottom of browser (i.e. pid=12345)
With this information you should able to create the issue using name, key or ID of your project.
Related
I find difficulty on how to pass attributes to a product using the woocommerce rest api.
I successfully took the attribute id.
my function:
def assign_attribute_to_products(wcapi_yachtcharterapp,post_id,attribute_id):
#the post_id argument is the product id
data = {
"attributes": [
{
"id": attribute_id,
},
],
}
wcapi_yachtcharterapp.put("products/"+str(post_id), data).json()
The product is updated without passing the information of attribute_id.
Any idea how to fix this?
You are missing some data, take a look here
This works for me:
data = {'attributes': [{'id': 7,
'options': ['term01', 'term02'],
'variation': 'true',
'visible': 'true'}]}
even though the data type for visible and variation is a boolean in the docs, you have to set 'true' or 'false' with a string.
You have to include the options for variations.
Hope this helps.
I'm using the python Facebook API's SDK.
I am currently able to request and obtain campaign insights from the account level, with a snippet as such:
from facebook_business.adobjects.adaccount import AdAccount
from facebook_business.adobjects.adsinsights import AdsInsights as Insights
account = AdAccount(u"act_{}".format(account_id))
report_params = {
'time_increment': time_increment,
'time_range': {
'since': start_date.strftime("%Y-%m-%d"),
'until': end_date.strftime("%Y-%m-%d"),
},
'level': 'campaign'
}
insights = account.get_insights(fields=['campaign_name', 'spend'],
params=report_params, pending=True).execute()
The problem is that I can't seem to get information about a deleted campaign, that was active for a time, meaning that it has a spend value.
Here I read that adding a filtering might give me also DELETED or ARCHIVED campaigns, but in the get_insights documentation page I can't seem to find a field to filter on, and every try has been unsuccessful
I found the right filter, even though the effective_status is not obtainable through insight fields, you can use it in filters, in my case I included every possible campaign.effective_status. Using the following report_params
report_params = {
'time_increment': time_increment,
'time_range': {
'since': start_date.strftime("%Y-%m-%d"),
'until': end_date.strftime("%Y-%m-%d"),
},
'level': 'campaign',
'filtering': [{'field': 'campaign.effective_status',
'operator': 'IN',
'value': ['ACTIVE', 'PAUSED', 'DELETED', 'PENDING_REVIEW', 'DISAPPROVED',
'PREAPPROVED', 'PENDING_BILLING_INFO', 'CAMPAIGN_PAUSED', 'ARCHIVED',
'ADSET_PAUSED']}]
}
I'm trying to add watchers after creating the issue using python but while adding into after creating issue getting below error, Can anyone help?
TypeError: unbound method add_watcher() must be called with JIRA instance as first argument (got unicode instance instead)
Code:
def aus_issue(self):
self.issue_aus = {
'project': {'key': 'MOS'},
'issuetype': {'name': 'Reporting'},
'summary': 'Test NDP Data Audit {} AUS'.format(Jira.date_create().strftime('%B')),
'description': self.description,
'customfield_10038': {'value': 'AUS'},
'customfield_10052': {'value': 'Ad hoc'},
'customfield_10053': {'value': 'Monthly'},
"assignee": {
"name": ""
}, 'duedate': str(Jira.sixth_day())}
self.create_aus = self.client.create_issue(fields=self.issue_aus, prefetch=True)
JIRA.add_watcher(self.create_aus.id, watcher='UserName')
In your code, the instance of JIRA class is: "self.client"
For add_watcher, you need to use it as:
self.client.add_watcher(self.create_aus.id, watcher='UserName')
I have simple question regarding the Magento V1 media API. I'm trying to add a video to a product but it keeps telling me that is missing values.
I'm trying to add the data from Odoo (python) like this:
videoFile = {
"entry": {
'position': position,
'media_type': 'external-video',
'disabled': False,
'label': 'Holassss',
'types': ['image', 'small-image', 'thumbnail'],
'content': {
'base64_encoded_data': base64.b64encode(urllib.request.urlopen("https://img.youtube.com/vi/axwE9q7llEQ/0.jpg").read()).decode('ascii'),
'type': 'image/jpeg',
'name': '0.jpg'
},
'extension_attributes': {
'video_content': {
'media_type': 'external-video',
'video_provider': 'youtube',
'video_url': 'https://www.youtube.com/watch?v=axwE9q7llEQ',
'video_title': 'Titulo',
'video_description': 'Description',
'video_metadata': None,
}
}
}
}
cc = json.dumps(videoFile)
productUrl = url + "/index.php/rest/V1/products/" + productSku + "/media"
Eventually I'll add the content using the https://www.youtube.com/oembed?url=youtubeurl&format=json response.
I'm following the API documentation (http://devdocs.magento.com/swagger/index_20.html) for
catalogProductAttributeMediaGalleryManagementV1 (/V1/products/{sku}/media)
Error:
"message": "Option values that are not specified."
Please advice me on which values I'm missing and which I can leave NULL. Also let me know if there is a way to let Magento automatically get the description and other data (as on the admin panel) instead of providing it myself. last but not least, I think this documentation is missing some data. This already happened to me before with a different call and a couple of "optional" values were actually required. Is there another documentation web page?
Thank you very much.
I'm using the smartsheet-python-sdk and I have a simple JSON file that I want to update my Smartsheet sheet with.
I have succeeded in pulling sheet data down using the python requests library but I'm wondering how exactly I would post data.
Here is the code:
import requests
accessToken = "xxxxxxxxxxxxxxxxxxxxxxxxxx"
baseUrl = "https://api.smartsheet.com/2.0/sheets"
req = requests.get(baseUrl, verify=False, headers = {"Authorization":"Bearer %s" %accessToken})
print(req.content)
I'd suggest checking out our API documentation, specifically the Python code samples section which provides a little more information. In addition, we provide code samples for almost all of our operations in the API documentation. Simply select Python when browsing the API docs.
In reference to posting data, that would depend on which operation you'd like to use. Here's an example of a "Create Sheet" operation:
# Create sheet in "Sheets" folder.
sheet = smartsheet.models.Sheet({
'name': 'newsheet',
'columns': [{
'title': 'Favorite',
'type': 'CHECKBOX',
'symbol': 'STAR'
}, {
'title': 'Primary Column',
'primary': True,
'type': 'TEXT_NUMBER'
}, {
'title': 'Status',
'type': 'PICKLIST',
'options': [
'Not Started',
'Started',
'Completed'
]
}
]
})
action = smartsheet.Home.create_sheet(sheet)
sheet = action.result
You can find similar examples for other operations. If you have additional questions, you can always reach out to our API support team: api#smartsheet.com