# Constructing a JSON in workflow using workflow variables

**URL:** <https://developer.sailpoint.com/discuss/t/constructing-a-json-in-workflow-using-workflow-variables/38707>\
**Category:** SHF Discussion and Questions\
**Tags:** identity-security-cloud, workflows\
**Created:** [April 2, 2024, 10:04am UTC](https://developer.sailpoint.com/discuss/t/constructing-a-json-in-workflow-using-workflow-variables/38707 "2024-04-02T10:04:16Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nadim](https://avatars.discourse-cdn.com/v4/letter/n/9dc877/32.png) [@Nadim](https://developer.sailpoint.com/discuss/u/Nadim)\
**Post date:** [April 2, 2024, 10:04am UTC](https://developer.sailpoint.com/discuss/t/constructing-a-json-in-workflow-using-workflow-variables/38707/1 "2024-04-02T10:04:16Z")

</div>

Hello,  
I am configuring a workflow and I need to send an HTTP request with a body in this workflow.  
the first element of the body is a static string that I define, but the second element of the body is a list that is a variable we got from a previous workflow operation.  
I have tried to create a body similar to the body created in this post [Chained Workflows](https://developer.sailpoint.com/discuss/t/chained-workflows/7329)

```auto
{
"application":"ApplicationA",
"result":"{{$.hTTPRequest.body}}"
}

```

but the output I see is not really a json list and the data cannot be used as intened.

I have tried to remove the quotes form the variable but then the workflow just returns an error.  
Is there a workaround for this?  
Regards.

---

<div class="post-metadata">

**Author:** ![ipobeidi](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/ipobeidi/32/16000_2.png) [@ipobeidi](https://developer.sailpoint.com/discuss/u/ipobeidi)\
**Post date:** [April 2, 2024, 12:24pm UTC](https://developer.sailpoint.com/discuss/t/constructing-a-json-in-workflow-using-workflow-variables/38707/2 "2024-04-02T12:24:58Z")

</div>

It needs to be something like this:

```auto
{
"application":"ApplicationA",
"result": [
{{$.request.Body}}

]
}

```

---

<div class="post-metadata">

**Author:** ![Nadim](https://avatars.discourse-cdn.com/v4/letter/n/9dc877/32.png) [@Nadim](https://developer.sailpoint.com/discuss/u/Nadim)\
**Post date:** [April 2, 2024, 1:17pm UTC](https://developer.sailpoint.com/discuss/t/constructing-a-json-in-workflow-using-workflow-variables/38707/3 "2024-04-02T13:17:52Z")

</div>

I have tried this but it did not work for me

---

<div class="post-metadata">

**Author:** ![iamnithesh](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/iamnithesh/32/42445_2.png) [@iamnithesh](https://developer.sailpoint.com/discuss/u/iamnithesh)\
**Post date:** [April 2, 2024, 1:44pm UTC](https://developer.sailpoint.com/discuss/t/constructing-a-json-in-workflow-using-workflow-variables/38707/5 "2024-04-02T13:44:28Z")

</div>

Can you share the contents of `$.hTTPRequest.body`

---

<div class="post-metadata">

**Author:** ![Nadim](https://avatars.discourse-cdn.com/v4/letter/n/9dc877/32.png) [@Nadim](https://developer.sailpoint.com/discuss/u/Nadim)\
**Post date:** [April 2, 2024, 2:01pm UTC](https://developer.sailpoint.com/discuss/t/constructing-a-json-in-workflow-using-workflow-variables/38707/6 "2024-04-02T14:01:55Z")

</div>

The content of the `$.hTTPRequest.body` is too big to share here, but it is the result of a search query made to IDN that returns a list of account activity

---

<div class="post-metadata">

**Author:** ![iamnithesh](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/iamnithesh/32/42445_2.png) [@iamnithesh](https://developer.sailpoint.com/discuss/u/iamnithesh)\
**Post date:** [April 2, 2024, 2:09pm UTC](https://developer.sailpoint.com/discuss/t/constructing-a-json-in-workflow-using-workflow-variables/38707/7 "2024-04-02T14:09:53Z")

</div>

What type of data do you get in the body? Array […] or Json {…}?

---

<div class="post-metadata">

**Author:** ![Nadim](https://avatars.discourse-cdn.com/v4/letter/n/9dc877/32.png) [@Nadim](https://developer.sailpoint.com/discuss/u/Nadim)\
**Post date:** [April 2, 2024, 2:22pm UTC](https://developer.sailpoint.com/discuss/t/constructing-a-json-in-workflow-using-workflow-variables/38707/8 "2024-04-02T14:22:32Z")

</div>

The data in the response body are in Array […] format

---

<div class="post-metadata">

**Author:** ![ipobeidi](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/ipobeidi/32/16000_2.png) [@ipobeidi](https://developer.sailpoint.com/discuss/u/ipobeidi)\
**Post date:** [April 2, 2024, 2:45pm UTC](https://developer.sailpoint.com/discuss/t/constructing-a-json-in-workflow-using-workflow-variables/38707/9 "2024-04-02T14:45:36Z")

</div>

Try this :

```auto
{
"application":"ApplicationA",
"result": 
{{$.request.body}}

}

```

---

<div class="post-metadata">

**Author:** ![Nadim](https://avatars.discourse-cdn.com/v4/letter/n/9dc877/32.png) [@Nadim](https://developer.sailpoint.com/discuss/u/Nadim)\
**Post date:** [April 2, 2024, 2:57pm UTC](https://developer.sailpoint.com/discuss/t/constructing-a-json-in-workflow-using-workflow-variables/38707/10 "2024-04-02T14:57:10Z")

</div>

I mentioned in my original post that I tried to have the body without the double quotes as you suggest but I still have an error.

the error is the following  
`Unable to parse input as JSON, please ensure it is syntactically correct. (type: Error Parsing Input, retryable: false): invalid character 'm' looking for beginning of value`

---

<div class="post-metadata">

**Author:** ![iamnithesh](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/iamnithesh/32/42445_2.png) [@iamnithesh](https://developer.sailpoint.com/discuss/u/iamnithesh)\
**Post date:** [April 3, 2024, 9:49pm UTC](https://developer.sailpoint.com/discuss/t/constructing-a-json-in-workflow-using-workflow-variables/38707/11 "2024-04-03T21:49:20Z")

</div>

Not sure if this will work. But try this one

```auto
{
"application":"ApplicationA",
"result":[{{$.hTTPRequest.body[*]}}]
}

```

---

<div class="post-metadata">

**Author:** ![Nadim](https://avatars.discourse-cdn.com/v4/letter/n/9dc877/32.png) [@Nadim](https://developer.sailpoint.com/discuss/u/Nadim)\
**Post date:** [April 4, 2024, 9:34am UTC](https://developer.sailpoint.com/discuss/t/constructing-a-json-in-workflow-using-workflow-variables/38707/12 "2024-04-04T09:34:29Z")

</div>

Unfortunately this did not work.

I also tested

```auto
{
"application":"ApplicationA",
"result":{{$.hTTPRequest.body[*]}}
}

```

but without any success

---

<div class="post-metadata">

**Author:** ![ipobeidi](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/ipobeidi/32/16000_2.png) [@ipobeidi](https://developer.sailpoint.com/discuss/u/ipobeidi)\
**Post date:** [April 4, 2024, 12:46pm UTC](https://developer.sailpoint.com/discuss/t/constructing-a-json-in-workflow-using-workflow-variables/38707/13 "2024-04-04T12:46:05Z")

</div>

i know is not necessary but can you use the step Define Variable and use the variable instead?

---

<div class="post-metadata">

**Author:** ![Nadim](https://avatars.discourse-cdn.com/v4/letter/n/9dc877/32.png) [@Nadim](https://developer.sailpoint.com/discuss/u/Nadim)\
**Post date:** [April 8, 2024, 9:39am UTC](https://developer.sailpoint.com/discuss/t/constructing-a-json-in-workflow-using-workflow-variables/38707/14 "2024-04-08T09:39:43Z")

</div>

Hello Ivan,

Your suggestion did not work for me

---

<div class="post-metadata">

**Author:** ![iamnithesh](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/iamnithesh/32/42445_2.png) [@iamnithesh](https://developer.sailpoint.com/discuss/u/iamnithesh)\
**Post date:** [April 9, 2024, 4:02pm UTC](https://developer.sailpoint.com/discuss/t/constructing-a-json-in-workflow-using-workflow-variables/38707/15 "2024-04-09T16:02:22Z")

</div>

Apparently `{{}}` does not work as a placeholder for arrays in templating. (They can be used for single variables only) Using any variation of `{{$.hTTPRequest.body}}` inserts a text string that is in the format `map[...]` where `...` is the actual content of the array. Also, every nested child array inside will also be prefixed with `map`. This is why you are getting the below error

> [@Nadim](#):
>
> invalid character ‘m’ looking for beginning of value

I guess you will have to look for another approach.

PS: Please share your findings as this is a very interesting use case

---

<div class="post-metadata">

**Author:** ![Nadim](https://avatars.discourse-cdn.com/v4/letter/n/9dc877/32.png) [@Nadim](https://developer.sailpoint.com/discuss/u/Nadim)\
**Post date:** [April 10, 2024, 7:13am UTC](https://developer.sailpoint.com/discuss/t/constructing-a-json-in-workflow-using-workflow-variables/38707/16 "2024-04-10T07:13:32Z")

</div>

Hello Nithesh,

Thank you for your answer. I was trying to look into an alternative by only sending the array in the body using the “choose variable” option and sending the information `"application":"ApplicationA"` in the request header as it is a static value that I define.

While I believe this can work easily in most cases it does not work for me as the receiving end on the HTTP request, is an external trigger of another workflow in IDN. And from what I tested I do not have a way of retrieving the headers from this trigger.

I am open for testing ideas and other methods of implementation if anyone can think of a possible solution.

A bad solution would be to create a new workflow with external trigger for each application but this is something we don’t want to do as we would be wasting our workflow limit in the environment

Regards,

---

<div class="post-metadata">

**Author:** ![skashyap007](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@skashyap007](https://developer.sailpoint.com/discuss/u/skashyap007)\
**Post date:** [June 7, 2024, 3:24pm UTC](https://developer.sailpoint.com/discuss/t/constructing-a-json-in-workflow-using-workflow-variables/38707/17 "2024-06-07T15:24:50Z")

</div>

Hey @Nadim , Were you able to find the alternate way to pass the values ?

Thank you,  
Sri

---

<div class="post-metadata">

**Author:** ![Nadim](https://avatars.discourse-cdn.com/v4/letter/n/9dc877/32.png) [@Nadim](https://developer.sailpoint.com/discuss/u/Nadim)\
**Post date:** [June 13, 2024, 9:45am UTC](https://developer.sailpoint.com/discuss/t/constructing-a-json-in-workflow-using-workflow-variables/38707/18 "2024-06-13T09:45:18Z")

</div>

Hello Srivasta,

Unfortunately we were unable to find any alternative solution for this issue.

Regards

---

<div class="post-metadata">

**Author:** ![skashyap007](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@skashyap007](https://developer.sailpoint.com/discuss/u/skashyap007)\
**Post date:** [June 13, 2024, 9:57am UTC](https://developer.sailpoint.com/discuss/t/constructing-a-json-in-workflow-using-workflow-variables/38707/19 "2024-06-13T09:57:55Z")

</div>

@Nadim thanks for the response, i figured it out.

> [@Workflow to revoke / Provision role to multiple identities](https://developer.sailpoint.com/discuss/t/workflow-to-revoke-provision-role-to-multiple-identities/64319/4):
>
> Yep, its working [image]

Thank you,  
Sri

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [August 12, 2024, 9:58am UTC](https://developer.sailpoint.com/discuss/t/constructing-a-json-in-workflow-using-workflow-variables/38707/20 "2024-08-12T09:58:48Z")

</div>

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