It's all about the answers!

Ask a question

Use dojo.xhrpost to create automatically a workitem


David MICHEL (1472448) | asked Oct 30 '12, 5:47 a.m.
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



5 answers



permanent link
Binoy D'costa (9532537) | answered Apr 15 '13, 5:12 p.m.
David,

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

Thanks,
Binoy

Comments
Rafael Hayama commented Apr 17 '13, 3:52 p.m. | edited Apr 17 '13, 3:56 p.m.

Hello Binoy,

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

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


permanent link
David MICHEL (1472448) | answered Nov 13 '12, 10:59 a.m.
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.




permanent link
David MICHEL (1472448) | answered Nov 06 '12, 10:08 a.m.
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 ?


permanent link
David MICHEL (1472448) | answered Oct 30 '12, 12:04 p.m.
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 ?

permanent link
Curtis d'Entremont (1.3k3) | answered Oct 30 '12, 11:32 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
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.

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.