Introducing the Goals API

where can I see the current version of opt_fields. Before that, I did not find any mention of any parent goal in the “goal” object in the documentation)

The documentation is a bit confusing, to get the list of potential fields you need to go to the “Get goal” endpoint and click on “200” (see arrows).

@Phil_Seeman am I missing something?

1 Like

The easier way to see a list of fields for any object is to click on the object name itself in the left-hand nav of the Reference tab:

image

(It did take me a little while to figure this out!)

it’s all good, I looked through this documentation many times but my problem is still not solved. how do i get the list of goals and its subgoals. opt_fields provide no data to the parent Target

Good question. I haven’t worked with goals at all yet, but testing just now, I don’t see parent as a property on the goal object. @Bastien_Siebman are we missing something?

The only way I can see to do it is to use the “Get goals” endpoint to get all of the goals, then loop through and call “Get subgoals from a goal” for each one, and see if you get any subgoals.

I hope I’m wrong as that’s a pretty ugly solution, but it’s the only option I can see at present.

@Phil_Seeman, I agree with you. I already thought about using your Baching API, but there is no guarantee that the request limit will not block me from a large number of goals. That’s why I decided to discuss it here. The personal account dashboard has exactly the block that I need, but you are using SSR and I cannot see the request there

FYI I’m an independent developer, I don’t work for Asana.

Also FYI the Asana web app does not use the Asana API, so seeing anything in the web app wouldn’t be helpful from an API standpoint anyway.

2 Likes

I assumed it was there, pretty sure it exists even if not documented… :thinking:

May I mention a developer who might know this or a support mail adress? This topic is important to me. :pray:

support@asana.com is the main support address. @Phil_Seeman and I are developer. While I can’t talk for me, in my case I charge for my time spent investigating :slight_smile:

1 Like

I tried asking for it in opt_fields in some Postman testing, used a few different strings, but was not able to get any of them to return a parent property…

@sasha_f @John_Vu @AndrewWong do you know if it’s possible to retrieve parent as a property of a Goal object?

Also, @anon93471150, you can email api-support@asana.com for API-specific questions.

1 Like

Hi everyone,

As @Phil_Seeman mentioned in an earlier comment we do not have a parent property on our Goals schema so asking for it in our opt_fields won’t return it. Also, I don’t believe we have an endpoint for “Get subgoals from a goal” so calling client.goals.get_subgoals_for_goal in our client libraries should not work.

@John_Rolfe and @anon93471150 I talked to our API team and brought up your use cases of:

  • “I am working on a big project that involves collecting all the gaols that are stored in Asana and showing them in a Tableau dashboard”
  • “My application has a similar visual as the goals page (list of goals and their subgoals with all the information) I don’t understand how I can get all this through the api”

Our API team says that there’s no easy way to accomplish this and asks if the community has any recommendations that you all would like to see us implement to help with these types of use cases.

For now a workaround might be to:

  1. Call our Get goals (GET /goals) endpoint to retrieve a list of goals
  2. For each of the goals in #1 make a request to our Get goal relationships (GET /goal_relationships) endpoint to get sub goals of a goal. Make sure to keep track of this and the goals prior
  3. For each goal/sub goal make a request to our Get a goal (GET /goals/{goal_gid}) to get the necessary data you need from the goal/sub goal. Optionally if you want to save on API calls you can ask for the properties you need from the goals in #1 so that you only have to worry about getting information for sub goals for step #3

Another option is if you have a goal and want to identify if it is a sub goal you can call our Get parent goals from a goal (GET /goals/{goal_gid}/parentGoals) endpoint. As of right now we don’t have an easy way to identify if a goal is a sub goal from the resource data.

One reason that our API team mentioned that we don’t have a parent property on a goal is because goals can have many parents and we haven’t discussed a great way to show this yet. Any recommendations would be great. I’ll pass that information along to our API team.

2 Likes

Thanks for the discussion and asking the question Maksim_Shpetyuk. I completely assumed it existed and would have built a tool around it before realising my mistake :sweat_smile:

A task can belong to several projects and this is represented with a memberships object, why not simply do an equivalent for goals? Or just gave parents as an array?

2 Likes

I solved my issues with the goals API along time ago. To make a long story short we found lots of bugs with the API wrapper provided by Asana. These errors had to with pagination of the results.
To solve this we went back to basics and we around the API wrapper and just used Python requests with loops to query the API directly. Crude, but more reliable.
If anyone is stuck and seeing errors like this please drop me a note.

:scream: as this been fixed since?

To be honest the code works well now with the work around so I have not revisited it - so maybe? I don’t know. My comment in Jun 22 details my pain at the time!

@John_Rolfe Thank you for sharing. Based off your story I am guessing the issue had to do with our python-asana client library. I remember us fixing some pagination issues with the library in a later version so it could be possible that this has been fixed now.

@Bastien_Siebman I asked as similar question to our API team and the answer I got was it should be possible but we needed to think about the design of how developers will use it (i.e. what should happen with updates and creates, how much complexity would it add, etc). One idea that came up was having a parents property on the goal as a boolean. I’ll pass your suggestion along to our API team:

A task can belong to several projects and this is represented with a memberships object, why not simply do an equivalent for goals? Or just gave parents as an array?

2 Likes

Hi dear,

do anybody have a clue, why my payload is incomplete for
a POST /goals/{goal_gid}/addSubgoal

[
    {
        "data": {
            "name": "PowerBI KW47",
            "team": "1201762610641299",
            "due_on": "2023-11-24T14:00:00.000Z",
            "start_on": "2023-11-19T23:00:00.000Z",
            "workspace": "1201193743562235",
            "html_notes": "<body>Automatisch angelegt</body>",
            "time_period": "1201193744388049",
            "is_workspace_level": false
        }
    }
]

What am i missing out?

I am only getting a [400] subgoal: Missing input
But i cannot see, what the issue is.
I can create a goal with this payload, but not a subgoal.
There is no documentation for the mandantory fields of subgoals

I haven’t worked with the Goals API yet, unfortunately.

@John_Vu @John_Baldo ?