Asana::Errors::NotFound when trying to retrieve `story` resource.

Hi Team Asana :wave:

Firstly, as a developer that has previously looked after API documentation and community forums, I’d like to congratulate you on a wonderfully documented API. So far I’ve been able to answer all of my questions reading through the docs, plus the language-specific examples you provide are invaluable. Thank you!

I’m bumping against a really bizarre error when trying to process a webhook sent to my Ruby on Rails application. I’m receiving the following webhook when a task is moved between sections and it looks perfectly sensible:

{
  "resource":"1199190913173550",
  "message":{
    "events":[
      {
        "user":{
          "gid":"1183526302702676",
          "resource_type":"user"
        },
        "created_at":"2020-11-19T13:53:11.417Z",
        "action":"added",
        "resource":{
          "gid":"1198695465724037",
          "resource_type":"story",
          "resource_subtype":"section_changed"
        },
        "parent":{
          "gid":"1199232058987245",
          "resource_type":"task",
          "resource_subtype":"default_task"
        }
      }
    ]
  }
}

I need to retrieve more information about the section_changed story and I therefore make the following API call to retrieve the story referenced in the webhook (GID 1198695465724037).

client.stories.get_story(story_gid: "1198695465724037")
Asana::Errors::NotFound (Either the request method and path supplied do not specify a known action in the API, or the object specified by the request does not exist.)

At this point I’m really confused. I don’t understand how the story doesn’t exist when it was referenced in a webhook just a few seconds prior.

I’m the first to suspect I’m doing something daft, though it feels like I’ve boiled this down to absolutely basics.

I’d really appreciate any assistance from the Asana Team or fellow developers.

Thank you!
Dave J

Hi @anon55000258,

That is odd, I agree.

How about using the API Explorer to see if you can access the story that way? That’ll let you at least know if the issue is with the actual data, or perhaps something in the stories.get_story call.

Let us know the outcome of that test.

Hi @Phil_Seeman

Thanks for your speedy reply! I’ve just authorized the API Explorer and tried to retrieve the story with the GID of 1198695465724037, though it unfortunately returned the same error:

GET /stories/1198695465724037?opt_fields=gid&limit=10
{"errors":[{"message":"story: Not a recognized ID: 1198695465724037","help":"For more information on API status codes and how to handle them, read the docs on errors: https://asana.com/developers/documentation/getting-started/errors"}]}

Digging through our error tracker, I’ve spotted a pattern. It seems that we’re struggling to retrieve story resources for more recently created Asana boards. That also means the webhooks registered for those boards are recently created, too. Is it possible there’s some kind of API issue fetching story records for recently created boards or tasks or webhooks?

Thanks again for your help, I really appreciate it :bowing_man:

Not that I’m aware of. @Ross_Grambo, any ideas why Dave is not able to retrieve these seemingly-valid stories?

Good morning @Phil_Seeman @Ross_Grambo :wave:

I wanted to drop you a quick update to avoid you spinning your wheels on this. I think I’ve been able to “fix” the issue by deleting all existing webhooks via the Asana API and then rotating the personal access token used by our application. After these actions, the webhooks we’re receiving seem to reference story resources that we can successfully retrieve.

For information, whilst debugging last night and this morning, we were experiencing a couple of strange issues, all of which lead to the above “radical” move to reset everything and start afresh.

  1. Last night we deleted all webhook registrations via the Asana API and confirmed this via a GET request to the webhooks endpoint which returned an empty collection. Strangely, we still continued to receive webhook notifications for activity on boards, suggesting our state in Asana was somehow out of sync?
  2. This morning we were trying to create a new webhook resource for a single board and repeatedly received the below error. We verified that the owner of the access token definitely had access to the board in question, plus webhooks were created yesterday for the same board and token without error.
    The authorization and request syntax was valid but the server is refusing to complete the request. This can happen if you try to read or write to objects or properties that the user does not have access to.

All in all, I think we somehow got our ourselves into some bizarre state that has been rectified by deleting all webhook registrations and cycling our personal access token.

Please don’t feel the need to investigate this further, though perhaps the above information is useful to you and/or helps another API user who encounters similar issues.

Thanks all!
Dave

3 Likes

Reviving a super long-dead thread here to say that I’m running into the same issue. I get a webhook alert when a section is changed, so I grab the story so I can get the old and new sections.

It fails most of the time. When I do a GET request on the relevant task that triggered it, I find a story there for section_changed, but it has a different ID.

I really don’t understand why this isn’t working—I don’t know how it’s possible for a story ID to be included in the webhook but not exist.