Expand my Community achievements bar.

Don’t miss the Workfront AMA: System Smarts & Strategic Starts! Ask your questions about keeping Workfront running smoothly, planning enhancements, reporting, or adoption, and get practical insights from Adobe experts.

Fusion Webhook response

Avatar

Level 3

Hello,

 

Sorry that this question is very basic, but I've been in and out of so many coding languages lately that I need to ask.
Can I webhook repsonse return an array?
I have a test scenario where I'm creating an array but when I send that array in a webhook response, it looks like it gets flattened into a data string separated by commas.
Makes me think a webhook response doesn't respect data types?

 

thanks,

Kelly

2 Replies

Avatar

Level 4

Hi @Kelly_StarzEnt,

 

When you say it gets flattened to data string what does this mean?

I have tested this and the response basically creates JSON representation of the array something like, for example here you can see response for array of user groups, and then the json array can be processed later on (also can be converted back to array by using "Parse JSON" module)

 

[    
   {
        "ID": "t",
        "name": "User t",
        "objCode": "GROUP",
        "owners": [
            {
                "ID": "tt",
                "name": "User",
                "objCode": "USER"
            }
        ]
    },
    {
        "ID": "tes",
        "name": "Group",
        "objCode": "GROUP",
        "owners": [
            {
                "ID": "tested",
                "name": "User",
                "objCode": "USER"
            }
        ]
    }
]

 

Hopefully this helps, please let me know if you have any other questions.

 

Best regards,
Ivan

Avatar

Level 1

Hello, yes you can.
Your JSON should look like this:

{
    "array": [
        {
            "ID": "t",
            "name": "User t",
            "objCode": "GROUP",
            "owners": [
                {
                    "ID": "tt",
                    "name": "User",
                    "objCode": "USER"
                }
            ]
        },
        {
            "ID": "tes",
            "name": "Group",
            "objCode": "GROUP",
            "owners": [
                {
                    "ID": "tested",
                    "name": "User",
                    "objCode": "USER"
                }
            ]
        }
    ]
}

Then, in the webhook, you will see it as a single item with an array inside.

AndrewShevchyk_0-1760117875746.png

However, if you send the JSON in this format:

[    
   {
        "ID": "t",
        "name": "User t",
        "objCode": "GROUP",
        "owners": [
            {
                "ID": "tt",
                "name": "User",
                "objCode": "USER"
            }
        ]
    },
    {
        "ID": "tes",
        "name": "Group",
        "objCode": "GROUP",
        "owners": [
            {
                "ID": "tested",
                "name": "User",
                "objCode": "USER"
            }
        ]
    }
]

Then it will create a bundle for each item, instead of one item containing the array.