Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Use dojo.xhrpost to create automatically a workitem

Hello,
   I can create a workitem as the following article describes:
    https://jazz.net/library/article/782/

Instead of opening a new workitem, I wish to create a workitem with a post html request. I can create it with "curl" command (https://jazz.net/wiki/bin/view/Main/ResourceOrientedWorkItemAPIv2).
So I want to know if it's possible to excute a post request with the dojo function, xhrpost, or another function.

Thank you in advance

Best regards

David



0 votes



5 answers

Permanent link
You can do most things with XHR POSTs that you can do with any other HTTP client. Though for security, the browser restricts you to only making POSTs to the current hostname you're on (that the page was originally loaded from). So you won't be able to do it from another page on another host. Other than that you can put anything in the body and add whatever headers you need. The browser will automate some things for you, like Accept and Accept-Encoding headers (gzip support), cookies, and authentication.

0 votes


Permanent link
Before to it in a pluggin, I have tried to custom attribut script (Calculated Values).
I trie with the following source code:
dojo.provide("org.example.workitems.providers.postrequest");
-------------------------
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");

(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;

dojo.declare("org.example.workitems.providers.postrequest", null, {
    getValue: function(attributeId, workItem, configuration) {
       
        var xhrArgs = {
          url: "https://<my server>/ccm/oslc/workitems/522/rtc_cm:com.ibm.team.scm.svn.linkType.workItem.s",
          postData: dojo.toJson({"rdf:resource":"http://www.david.com","oslc_cm:label":"add a new comment"}),
          handleAs: "json",
         // headers:
        }
        dojo.xhrPost(xhrArgs);
       
        return "system impact";
       
    }
});
})();
--------------------------
This source code doesn't work. Do you think that it can work ?
What is different to execute dojo code source througth a plugin and to execute dojo code source throught custom attribut ?

0 votes


Permanent link
In my log server, I have this error:
org.mozilla.javascript.EcmaError: TypeError: Cannot find function xhrPost in object [object Object]

So I think I must to add some require but what ?

0 votes


Permanent link
Finally I managed to perform this source code. I have integrated it in javascript plugin and it's OK.
Also I have added some header.to accept json application.



0 votes


Permanent link
David,

So it didn't work within the javascript API? you had to write a eclipse plugin?

Thanks,
Binoy

0 votes

Comments

Hello Binoy,

Yes, extending RTC using its APIs requires an Eclipse plugin.

Please, see this article: https://jazz.net/library/article/784/

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,926
× 62
× 34

Question asked: Oct 30 '12, 5:47 a.m.

Question was seen: 8,623 times

Last updated: Apr 17 '13, 3:56 p.m.

Confirmation Cancel Confirm