Worklflow : json path expression

with the following input :

 {
                "accountId": "test.admin",
                "accountOperation": "Create",
                "attributeRequests": [
                    {
                        "attributeName": "groups",
                        "attributeValue": "[111, 110]",
                        "operation": "Add"
                    }
                ],
                "provisioningResult": "Manual Task Created",
                "provisioningTarget": "Manual",
                "source": {
                    "id": "test5d68cb437eb86481c77e63751btest",
                    "name": "Profil _Metest",
                    "type": "SOURCE"
                },
                "ticketId": null
}

i want to retrieve attributeValue when attributeName == groups

Iā€™m able to do that with filter :

$.attributeRequests[?(@.attributeName=='groups')].attributeValue

But i have the folling output :
image

I want to retrieve it in following format : [111, 110]

Is anyone have a solution for do that ?

Hi @baoussounda ,

Youā€™re using the correct JOSN path expression, which will return the desired value.

$.attributeRequests[?(@.attributeName == 'groups')].attributeValue

@amishra97 but i have following value :

image

And i want this format : [111, 110]

JSONpath cannot unpack that array since it is technically a string. If your attribute value looked like this (i.e. without the double quotes)

"attributeValue": [111, 110]

Then you could write this JSONpath expression

$.attributeRequests[?(@.attributeName=='groups')].attributeValue[*]

Which would produce the result you are looking for.

Hi @colin_mckibben,

This expression : $.attributeRequests[?(@.attributeName==ā€˜groupsā€™)].attributeValue[*]

return an empty array as you can see here :

I think itā€™s due attributeValue that was string.

Yes thatā€™s correct. That jsonpath express would only work if the attribute value was an array instead of a string. Ultimately, you canā€™t unpack that string the way you want with jsonpath.

1 Like

I will see if i can found another solution.

I have a worfklow that use ā€œProvisioning completedā€ trigger for specific delimited file and create automatically account in that source after manual action completion.

In my http request action i do post on /v3/accounts :
image

{
    "attributes": {
        "groups": "{{$.loop.loopInput.attributeRequests[?(@.attributeName=='groups')].attributeValue}}",
        "id": "{{$.loop.context.attributes.uid}}",
        "sourceId": "{{$.loop.loopInput.source.id}}"
    }
}

iā€™m able to create account on that source , but a multivalued entitlement attribute groups is populated like this :

But i can see that entitlement is correctly assigned, that means a ā€˜groupsā€™ is correctly populated ?

With postman, i have the following value in groups

image

But with this two cases, entitlements are assigned correctly.

This populated my delemited file source entitlement with bad data :

Bonjour,

I resolve this problem by combine two workflows.

In my second workflow use define varaible for replace [ by empty and in my http call for create or update account i add [ and ].

image

With ā€œ[122,142]ā€ ==> define variable output is : 122,142

and i call api with : [ 122,142]

Best regards