locked
TFS 2017 Create Workitem from extension using REST API RRS feed

  • Question

  • Hi,

    I am trying to create a new task workitem from inside a custom form control extension. But when I call the createWorkitem method, I get the following error : "Resource not available for anonymous access. Client authentication required", the status code is 401 Unauthorized. Here is the code I am using :

    require(["TFS/WorkItemTracking/Services", "TFS/WorkItemTracking/RestClient", "VSS/Service"], function (_WorkItemServices, _WorkItemTrackingClient, _Service)
    {
    var client = _Service.getCollectionClient(_WorkItemTrackingClient.WorkItemTrackingHttpClient);
    }
    var title = "something";
    var area = "validArea";
    
    var jsonPatchDoc = [
    {
       op: "add",
       path: "/fields/System.Title",
       value: title
    }];
    
    client.createWorkItem(jsonPatchDoc, area, "Tâche").then(function (wi)
       {
       alert("Task created!");
       });

    My TFS Server is in french, so my workitem Task is named "Tâche" its normal. 

    I am able to access the REST API because the "getRelationTypes" method works. The problem is not there.

    I also added the scope : "vso.work_write" to have the permission to create workitems.

    On the TFS server in the event viewer I have this error :

    Token validation failed for issuer gtfs2017test. Token scope claim not valid for request


    Can you help me?

    Maxime

    Tuesday, October 17, 2017 3:41 PM