Workflow - HTTP REQUEST

Hi,

I’m using HTTP request in workflow to check whether the Campaign is having a tag “REMINDER”. How can i catch exceptions in workflow.

here my trigger point is 1.) “CAMPAIGN ACTIVATED”.
2.) HTTP REQUEST → GET → “https://tenant-sb.api.identitynow.com/beta/tagged-objects/CAMPAIGN/id” to get tags on campaign.
3.) Compare Strings → To check whether campaign body.tags contains “REMINDER”
4.)If True → ADD 14 days to the $modifieddate, else end step.
5.) HTTP REQUEST → POST-> “https://tenant-sb.api.identitynow.com/beta/campaign/ID” → to update deadline date with new modified date.

Here the problem is, Not all the campaign that gets activated are tagged. So i’m looking for an option to catch the exception for untagged campaigns.

You can check the length of the tags array in the response object from the first HTTP Request to see if it’s 0. If it is 0, then you know there aren’t any tags on the campaign that was activated, and you can decide what to do from there like assign a default tag or send an email to notify the creator.

Use the “Compare Numbers” operator after your HTTP Request to get the tags and before you compare the strings. Configure it as follows.

1 Like

@colin_mckibben

Thanks for your reply.

I have tested this by creating a campaign, there is no tag added to this campaign. I’m using the below endpoint to see the list of tags for the campaign. But it throws error (attached below).

https://tenant.api.identitynow.com/beta/tagged-objects/CAMPAIGN/c*****7f1f4941a1a72da1dc05*****6

Looks like the API will return a 404 instead of an empty tags array if you are looking for an object that doesn’t have any tags. Workflows doesn’t yet have the ability to handle non 2xx response codes from the HTTP request, so you can’t catch the 404 and deal with in a comparison operator.

However, you can use the filters query param to search for a tagged object that matches the campaign ID, and if none exists it will return an empty array. Use this endpoint instead, replacing {campaignId} with your ID.

{{baseUrl}}/beta/tagged-objects?filters=objectRef.id eq "{campaignId}"

If that object has any tags, it will return an array with one item:

[
    {
        "objectRef": {
            "type": "IDENTITY",
            "id": "2c9180867dfe6951017e208e327c5ae3",
            "name": null
        },
        "tags": [
            "STARTS_WITH_A",
            "RISKY"
        ]
    }
]

If that object doesn’t have any tags, it will return an empty array:

[]

Check the length of the array using the Compare Numbers operator with this JSONpath:

$.length()

If it’s greater than 0, then your object has a tag, otherwise it doesn’t have a tag.

2 Likes

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