API query in custom action behaves different depending on trigger

Hi,

I currently work on an integration that uses the API v2 to get some item fields in a custom action. But the query returns different response depending on the trigger that is used. If I use a trigger that directly calls the action, like ‘when status changes’ or ‘when an update is created’, then the query with the provided itemId is successful. But when a time trigger, like ‘scheduled trigger’ or ‘when date has passed’ fires and calls the same action, then the query with a valid itemId fails with message ‘Variable itemId of type Int! was provided invalid value’.
Any ideas what is going wrong here?

Thanks, Marcus

Hi Marcus, @nyxophyl

I made it a habit to always parse id’s to an Int before calling the monday API functions. Would that solve your issue?

Hi @nyxophyl!

In addition, I would check the post body and see what formatting the itemId is returned as.

If you want to provide a screenshot, I’m happy to compare and see if I can reproduce.

Thanks

Hi.
@Helen and @basdebruin thanks for your hints. And yes, Bas, you are totally right. After I parse the itemId to an int and provide it then to the monday API function, it works for both cases (direct and time based triggers). It is still curious why there is a difference when I use the itemId without parsing (the integration runs as a node.js application), but I think it is hard to find out.
Thanks again and CU, Marcus

hi @nyxophyl , Marcus,

It depends how you declare variable in nodeJS. If you don’t declare the variable returned by the API the variable will be of the type returned (which is always as string). Therefore you need to parseInt all boardId, ItemId, personId, TeamId and others. I agree it would be nice if the API allows strings as it also returns strings :slight_smile: .

1 Like

With some further logging of the integration I observed that the payload contains different types for the itemId depending on the performed trigger. As mentioned in my initial post, e.g. the triggers ‘when status changes’ or ‘when an update is created’ provides the itemId as number/integer, and the triggers like ‘scheduled trigger’ or ‘when date has passed’ send the itemId as string. That’s why I stumbled upon, because I did no cast the itemId when using the monday API functions and was wondering about the different behavior. @Helen maybe you want to take that with you if it makes sense to unify the types of ids in the payload for all kind of triggers.

Hi @nyxophyl!

I actually just tested this out and I was able to get the itemId returned as a string when using the “When status changes” trigger. Maybe you’re seeing a different result based on how you’re getting the response?

Hi @Helen
for all recipes I built, I did the same: each of the used trigger have the itemId as output field and I just uses this as the trigger output field key for the itemId field in my custom action. Did you try the same? Could it be that we see different versions of the triggers?

Hmm I don’t think we would be seeing different versions of the triggers.

If you want to write into appsupport@monday.com, I’m happy to troubleshoot this as a bug with you and see if we need to get our developers involved!

Thanks~

I sent an email to appsupport and also mentioned this thread. Looking forward to their opinion.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.