It's all about the answers!

Ask a question

How to update severity/state of work item usinfg REST api ?


Rupam Roy (623) | asked Jan 16 '15, 6:15 a.m.
Hi,
Can anybody tell how to update severity/state of work item using REST api in RTC 4.0.6 ?

Ref url:
https://jazz.net/wiki/bin/view/Main/ResourceOrientedWorkItemAPIv2#Update_a_Work_Item
It is not working.

2 answers



permanent link
Jonas Studer (207917) | answered Jan 16 '15, 7:48 a.m.
Hy Rupam,

Maybe this link could help
https://jazz.net/wiki/bin/view/Main/CqOslcV2#POST

Comments
Rupam Roy commented Jan 16 '15, 8:43 a.m.

Hi Jonas,

I have tried your link. But this is not working.

I am getting error.. like

  • {
  •    "errorClass": "com.ibm.team.repository.common.CSRFException",
  •    "errorCode": 403,
  •    "errorTraceMarshall":
  • But I can update title, summary using rest api.


    permanent link
    Jonas Studer (207917) | answered Jan 16 '15, 8:57 a.m.
    I've already done a state Change.
    That's the way I do it.

    1: Require this:
    var WorkItemProxyFactory = com.ibm.team.workitem.web.cache.internal.WorkItemProxyFactory;

    2: Load the wished Workitem:
    this.workingCopyProxy = WorkItemProxyFactory.getWorkItemProxy({id: this.currentId, createIfNeeded: true, doNotCache: true, doNotGetFromCache:true});
    this.workingCopyProxy.initialize({});

    3: Check the state you have. Because you have to stick to the logic... new -> open -> done.
    This means, you can't directly change from new to done.

    E.g.
       var proxyState = this.workingCopyProxy.getValue({path: 'attributes.internalState.label'});
       var aValues= this.workingCopyProxy.getEditPropsValuesForAttribute('actionValues');
              
       if (proxyState == 'Done') {
               console.log('This is Done. Do nothing')
       } etc

    ---------------------
           _changeStartWorkingToDone: function() {
               var action_id = this._getWorkflowActionIdWCopy('Set Done', this.workingCopyProxy);
               if (action_id != '') {
                   var params = this._getParamsForWorkflowAction(action_id);
                   this.workingCopyProxy.setValue(params);
                   this.workingCopyProxy.storeWorkItem({
                       operationMsg: 'Saving',
                       applyDelta: true,
                       onSuccess: function(parms) {
                       },
                       onError: function(error) {
                           console.log(error);
                       }
                   });
               }
           },

           _getWorkflowActionIdWCopy: function(actionLabel, workingCopy) {
               var aValues = workingCopy.getEditPropsValuesForAttribute('actionValues');
               console.log(aValues.length);
               console.log(">>>>>>>>>>>>>>>><");
               var action_id = '';
               for (i in aValues) {
                   if (aValues[i].label == actionLabel) {
                       action_id = aValues[i].id;
                       break;
                   }
               }
               return action_id;
           },
    -----------
           _getParamsForWorkflowAction: function(action_id) {
               var params = {};
               params.attributeId = 'workflowAction';
               params.isInitialization = false;
               params.path = ["attributes", "workflowAction", "id"];
               params.value = action_id;
               return params;
           },

    Comments
    Rupam Roy commented Jan 19 '15, 2:55 a.m.

    Thanks Jonas,
    But
    I need to update using REST api.


    Jonas Studer commented Jan 29 '15, 8:54 a.m.

    Hy Rupam,

    Those functions USE REST, but they are built from those "developers".
    It's a little trick, to learn, how they do REST-Querys...

    A little example I'm working with now.
    I've tried to get absences from a user.
    So I've started membersclient.getAbsences.

    But if you watch Firebug when you load that function (watch the "net->XHR" Tab) then you see the whole REST Query, with head and every thing.
    E.g.
    https://localhost:7443/jazz/service/com.ibm.team.apt.internal.service.rest.IResourcePlanningRestService/absences?contributorId=_zP_coJleEd-joaYjvz6g2w

    Also, you could see al the parameters which are passed.

    Your answer


    Register or to post your answer.


    Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.