Malformed custom rule action json

The json payload for a custom rule action that Asana sends to my app server appears to be malformed. The documentation shows it to be one way but the actual json I receive is very different.

This is what I’m getting.

{"data":"{\"workspace\":number,\"project\":number,\"target_object\":number,\"action_type\":\"string\",\"action\":\"string\",\"user\":number,\"idempotency_key\":\"string\",\"expires_at\":\"2023-01-12T15:27:13.793Z\"}"}

And this is what the docs say I should be getting.

{
  "action": "string",
  "action_type": "string",
  "expires_at": "2019-04-15T01:01:46.055Z",
  "idempotency_key": "string",
  "target_object": "string",
  "user": "54321",
  "workspace": "12345"
}

Three things to note:

  1. The json I’m receiving is encapsulated in a “data” property whereas the docs example is not.
  2. The value of the “data” property is a string rather than additional json key/value pairs.
  3. The values for workspace, project, and target_object are represented as numbers instead of strings.

The rule that creates this json payload has a trigger of task due date being set. I checked a couple other trigger types and they produce the same unexpected behavior.

Is there something I can change on my end that would fix this, or am I overlooking something more obvious?

Hi,

Couple of things I hope will help:

  • very often there is a data wrapper, and I struggled as well in some cases but the doc is probably missing this part
  • I have seen this as well, and used JSON.parse on it do get the object
  • gid are definitely strings in the Asana world and not numbers, maybe this is a bug, you can turn the number into a string

If you fix those and don’t follow the documentation, it should work (I created a rule last week worked fine in the end).

@AndrewWong maybe you want to jump in as well?

1 Like

Good to know I wasn’t the only one experiencing this. I will report this as a bug so the next person doesn’t have to go through the same heartache that we went through. Of course fixing it will break all the workarounds that everyone has had to put into place to get it working.

Or can this topic be moved to the bug category? It looks like I would effectively be duplicating this entry in the system.

Moved!

Well, sorry, guys, I moved it back; I know the forum moderators and the DevRel team prefer to keep developer issues in the API forum section and reserve “Bugs” for user bugs.

I know your #3 - IDs coming back as numbers rather than strings - is a known issue. Not sure if/when they’re going to fix that.

1 Like