Search code examples
attaskworkfront-api

WorkFront (AtTask) API - Create new baseline for project


Is it possible to use the WorkFront API to to create a new baseline for a project by it's ID?

For example, when I create a baseline using the WorkFront UI, if I open devtools/Network in chrome I can see there is a POST request to attask/api-internal/BLIN, from what I can see the request should look something like this with the parameters: https://<COMPANY>.attask-ondemand.com/attask/api-internal/BLIN/fields=["objCode","ID","projectID","name","isDefault"]&method=post&updates={"objCode":"BLIN","ID":"","projectID":"<PROJECT_ID>","name":"NEW_BASELINE","isDefault":false}

So I've tried that using Postman and I get a response

"error": {
    "class": "com.attask.common.AuthenticationException",
    "message": "You are not currently logged in"
}

I get the same message if I append the API key to the URL with ...&apiKey=<API_KEY>

From there I've tried logging in to get a session ID, then I've mixed and matched adding the sessionID and apiKey to the end of the URL etc. When I use the sessionID I get the following error:

"error": {
    "class": "java.lang.IllegalArgumentException",
    "message": "method POST is not allowed for authorization type COOKIE"
}

What might I be doing wrong? Is this even possible to achieve using the API?


Solution

  • You got almost all the way there. You don't need to pass the fields since they're implicitly defined when you pass the updates. This should work for you:

    https://<domain>.my.workfrontcom/attask/api/v6.0/BLIN?updates={"objCode":"BLIN","ID":"","projectID":"<projectID>","name":"<baseline name>","isDefault":false}&apiKey=<api key>
    

    Make sure that you submit this as a POST.