I'm using the java and the Workfront API to create a new task and would like to specify a predecessor while creating the task. If I add the task first, then update it, I am able to add the predecessor but I'd prefer to specify the predecessor when adding the task if possible.
Here's what I've tried but I have no luck. I just get a 500 error (internal server error).
...
Map<String, Object> map = new HashMap<String, Object>();
map.put( "name", "Test Task" );
map.put( "projectID", projectId );
JSONArray array = new JSONArray();
JSONObject jsonObj = new JSONObject();
jsonObj.put( "predecessorID", predecessorId );
jsonObj.put( "predecessorType", "fs" );
array.put( jsonObj );
map.put( "predecessors", array );
client.post( "task", map );
Has anyone been able to do this? Am I just missing something?
I'm almost positive that you can't set dependencies in the same operation as object creation. You'll have to PUT an update on the object after its creation. I'm not sure about the syntax for your Java implementation, but this is what the raw HTTP call would look like:
PUT https://<url>.my.workfront.com/attask/api/v9.0/task/<uuid>?updates={predecessors:[{predecessorID:"<ID of dep>",predecessorType:"<ss/sf/fs/ff>"}]}&apiKey=<key>