Search code examples
attaskworkfront-api

WorkFront (AtTask) assign Task


I am having my challenges using WorkFronts API. My current problem is that I cannot figure out how to use their assign action method. WorkFront's documentation says that the assign method accepts two arguments; objID and objCode. Below is what I have currently. I have tried other URL's, but I keep getting the same error message. The error that is being returned is NullPointerException. If anybody could help that would be great. Also if you happen to have working examples that you could pass my way or some kind of documentation. I have these two URL's; https://developers.workfront.com/api-docs/ and https://developers.workfront.com/api-docs/api-explorer/. The API Explorer API shows you the assign action method on the Task object.

    using (var apiManagementSystem = new HttpClient())
    {
        apiManagementSystem.BaseAddress = new Uri("https://xxxxxxx.preview.workfront.com/attask/api/");
        apiManagementSystem.DefaultRequestHeaders.Clear();

        var jsonMediaType = new MediaTypeWithQualityHeaderValue("application/json");
        apiManagementSystem.DefaultRequestHeaders.Accept.Add(jsonMediaType);
        apiManagementSystem.DefaultRequestHeaders.Add("SessionID", _sessionID);

        HttpContent httpContent = null;
        responseMessage = apiManagementSystem.PutAsync("v6.0/TASK/TASKID/assign?objID=TASKID&objCode=TASK&apiKey=ApiKey", httpContent).Result;

    }

Solution

  • You need to invoke the assign method under the object that you wish assign an object to (the work) to and then provide as arguments the ID and type of the object that you are assigning (the worker).

    For example: <baseurl>/task/<taskID>/assign?objID=<userID>&objCode=USER

    The above snippet would assign the user specified by userID to the task specified by taskID. Ensure that you pass the call as a PUT method.

    Valid assignee object types are: users, roles, or teams.