How to assign project category to a project using JIRA rest apis - jira-rest-api

How to assign project category to a project using JIRA rest apis.
My Jira server version is 6.3.13

All the following is using python!
If you are creating a new issue you can do it in two different ways, the first being a dict:
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)
The second way is to do it all in the function call:
new_issue = jira.create_issue(project='PROJ_key_or_id', summary='New issue from jira-python',
description='Look into this one', issuetype={'name': 'Bug'})
However if you are updating a existing issue then you have to use the .update() function. Which would look like this:
new_issue.update(issuetype={'name' : 'Bug'})
Source: http://pythonhosted.org/jira/

Related

WooCommerce REST API Custom Fields

Is it possible to access custom fields for orders, products, customers via WooCommerce REST API? If not natively, then what plugins or workarounds or hacks are out there that work? Thanks!
Answering my own question:
It is possible using the following: (using v3 legacy API)
To send custom fields back to the server:
(For Orders)
{
"order_meta": {
"key": "value"
}
}
To retrieve custom fields from server use this filter with your end point:
http://www.example.com/wc-api/v3/orders?filter[meta]=true
This works for Products as well.
As mentioned in the comment after WooCommerce creates an order via the API it will fire woocommerce_api_create_order hook, you can make use of it.
Add the following code to your theme's functions.php file
add_action( 'woocommerce_api_create_order', 'my_woocommerce_api_create_order', 10, 2);
function my_woocommerce_api_create_order( $order_id, $data ) {
// $data contains the data was posted, add code to extract the required
// fields and process it as required
}
Similarly look at the code in plugins/woocommerce/includes/api/*.php files, find the suitable action or filter hook for the end point and use it.
SIMPLE SOLUTION THAT WORKED FOR ME (using REST API REQUEST):
URL: https:///wp-json/wc/v3/orders/1234
METHOD: PUT
BODY:
{
"status": "completed",
"meta_data": [{
"key": "is_web_server_handled",
"value": "1"
}]
}

Worklight WL.JSONStore Replace Doc failed

I have initialize a collection. In that i have a single doc which holds UserPreferences. I an trying to updated few fields of this doc. But fails with errorCallback.
var dataToUpdate = {
userPreferencesID:1,
firstname:'Test Name',
lastName: 'Test Name 2'};
WL.JSONStore.get(tableName).replace(dataToUpdate).then(successCallback).fail(errorCallback);
If some forum i could see the syntax
WL.JSONStore.get(tableName).replace(query, option).then(successCallback).fail(errorCallback);
Which one is correct. I tried both, but failed to update the record.
IBM Worklight Version 6.1.0.2
Thank in advance.
The replace API takes a JSONStore document as the first parameter. For example:
{_id: 1, json: {userPreferencesID: 1, firstname: 'Test Name', lastName: 'Test Name 2'}}
Notice the _id and json keys. You're not passing a document as the first parameter.
Here's the API documentation for the replace API in Worklight v6.1.
You get JSONStore documents when you use, for example, the findAll API:
WL.JSONStore.get('collection').findAll()
.then(function (jsonstoreDocuments) {
// [{_id: 1, json: {name: 'carlitos', age: 99}}]
});
The example above presumes the JSONStore collection is not empty, if it's empty you'll get an empty array back (i.e. []).

RallyDataSource.update is not working for portfolioitem/feature (works for userstories)

Here is the API verison I am using:
script type="text/javascript" src="/apps/1.33/sdk.js?apiVersion=1.43"></script>
The goal is to display a portfolio item/feature and all the child user stories of the feature in a grid. Then based on the US fields value, update the value of the field of the portfolio item/feature.
I am able to update the release field of a UserStory using rallydatasource.update command, but the same command doesn't work for updating fields of portfolio item/feature
Here are the fields I am trying to update for Feature. These do not work
rallyDataSource.update({_ref:ref, GroomingState: nfGroomingState},onUpdateComplete,onError);
rallyDataSource.update({_ref:ref, c_GroomingState: nfGroomingState},onUpdateComplete,onError);
rallyDataSource.update({_ref:ref, Ready: true},onUpdateComplete,onError);
rallyDataSource.update({_ref:ref, Notes: "This is test"},onUpdateComplete,onError);
rallyDataSource.update({_ref:ref, Architect: "XYZ ABC"},onUpdateComplete,onError);
Here are the fields I am trying to update for UserStory. This does work.
rallyDataSource.update({
"_ref":sRef,
"Release": [
{
ref:relRef
}
]},
onUpdateComplete,onError);
Can someone please help me understand if there is something I am doing wrong?
Is update to portfolio item not supported in v 1.43?
You are using a trick ?apiVersion=1.43 to set the WS API version to the version the legacy AppSDK1 predates and does not support, and it works to the extent but not enough to get the updates working.
I suggest AppSDK2
Also, since State of PI types is a full object (unlike State or ScheduleState of Defects or UserStories) a _ref has to be used in this code: GroomingState: nfGroomingState You may be using the reference, it was not clear from the code fragment. There is a Ruby example here that works with PI states. Rally Ruby toolkit sits on the same WS API model, so that example is not entirely irrelevant.
Here are the details of what I tried with AppSDK1 set to use version 1.43 of WS API.
Regardless how I set the version either using src="/apps/1.33/sdk.js?apiVersion=1.43" or rallyDataSource.setApiVersion("1.43"); I have to use parent type:
PortfolioItem
instead of concrete PortfolioItem/Feature type when I query:
function itemQuery() {
var queryObject = {
key: "pi",
//type: "PortfolioItem/Feature", //does not work
type: "PortfolioItem",
fetch: "FormattedID,Parent,State,Name",
query: "(Parent.FormattedID = I8)"
};
rallyDataSource.findAll(queryObject, populateTable);
}
This works fine, and all children of PortfolioItem/Initiative I8, which are of type PortfolioItem/Feature are returned successfully, and if all I want to do is to build a grid, it works:
function populateTable(results) {
var tableDiv = document.getElementById('aDiv');
for (var i=0; i < results.pi.length; i++) {
var config = { columns:
[{key: 'FormattedID', header: 'Formatted ID', width: 100},
{key: 'State.Name', header: 'State', width: 100},
]};
var table = new rally.sdk.ui.Table(config);
table.addRows(results.pi);
table.display(tableDiv);
};
Two features are returned, one that has State already set, the other with no State:
However if I try to add the update function:
function populateTable(results) {
var tableDiv = document.getElementById('aDiv');
for (var i=0; i < results.pi.length; i++) {
if(results.pi[i].State === null){
console.log('state:',results.pi[i].State)
rallyDataSource.update({"_ref":results.pi[i]._ref, "State": "https://rally1.rallydev.com/slm/webservice/v2.0/state/12352608621"});
}
}
//...
"Requested type name "feature" is unknown error is returned:
OperationResult: ObjectErrors: Array[1]0: "Requested type name "feature" is unknown."length: 1__proto__: Array[0]Warnings: Array[1]0: "Please update your client to use the latest version of the API. You can find the latest version at https://rally1.rallydev.com/slm/doc/webservice/index.jsp?version=v2.0. No new projects should use this version of the API as it will be removed in the future."length: 1
AppSDK1 works with WS API that is no longer supported. Last supported date for 1.43 was June 20 of this year. AppSDK1 stopped at 1.32 of WS API. That is the reason for the trick to set WS API version because PortfolioItems were introduced in 1.37 of WS API. Particularly when you use features introduced after AppSDK1 was no longer updated (see WS API versioning) there is no guarantee that the rallyDataSource.setApiVersion("1.43"); trick will work in all scenarios.

How do you get field properties

I'm working on a Sencha app and having trouble accessing the fields of a basic model that I've defined. I use Ext.define to define a model and Ext.create to create an instance of it. According to the docs I should be able to access its fields by calling get.(<fieldname>) on the field, but it's not working and it's returning null. Here's the basic code, along with a jsfiddle.
Ext.define('App.model.Patient', {
extend: 'Ext.data.Model',
config: {
fields: ['admissionGuid',
'firstName', 'middleInitial', 'lastName', 'visitType',
{ name: "visitDate", type: 'date'}]
}
});​
var newVisit = Ext.create('App.model.Patient', {
admissionGuid: 1234,
firstName: "FirstName",
middleName: "MiddleName",
lastName: "LastName",
visitType: "Revisit",
visitDate: new Date()
});
alert(newVisit.get('admissionGuid')); // returns null
Your code is correct using Sencha Touch 2. I've tested it, and it works as expected. Fiddle here using ST: http://www.senchafiddle.com/#6Q9ac
ExtJS and Sencha Touch share similar class systems, but they are not identical.
The data that you passed gets stored in the raw parameter so try this
alert(newVisit.raw.admissionGuid);
This should work
just an alternative way,
we can also access the data inside model by:
*instanceOfModel*.data.*fieldName*
so for example with the given code it will be:
newVisit.data.admissionGuid

WCF table data to ExtJS Store

I've set up a WCF service to provide table data in JSON:
{
"d":{
"__type":"ExtJsDataResults:#MyProject.WebServices",
"rows":[
["TitleA","1.98","English"],
["TitleB","1.98","Spanish"],
["TitleC","1.98","Korean"]
],
"totalcount":10
}
}
How to read this into an ExtJS Store? I need a JsonStore to begin with, but then an ArrayReader-type type interpret the row data. Something like this:
var itemStore = new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: "../WebServices/ItemsService.svc/getData",
method: "GET"
}),
root: "d.rows",
totalProperty: "d.totalcount",
fields: ['Book Title', 'Unit Price', 'Language'],
reader: new Ext.data.ArrayReader({},
Ext.data.Record.create([
{name:'Book Title'},
{name:'Unit Price'},
{name:'Language'}
])
)
});
Of course, this doesn't work. When bound to a DataGrid w/ a paging toolbar, it displays blank rows, but the correct number of them, and the paging toolbar values are all correct.
Any ideas?
FIXED. Changed to a regular Store and added the "root" and "totalProperty" values to the config object of the ArrayReader.
cf. this Sencha Forum thread
I was also facing this problem but got through with this solution -
http://dotnetkeeda.blogspot.in/2013/11/working-with-sencha-extjs-and-wcf.html
Nice and important tips thanks to the author.