0

I have this JSON array which I am passing as part of an http request body:

enter image description here

Here is the string:

"peoplePickerInput":"[ { \"Key\":\"@{items('Apply_to_each_-_Certificates_2')?['EmailAddressNo1']}\"},{ \"Key\":\"@{items('Apply_to_each_-_Certificates_2')?['EmailAddressNo2']}\" } ]"

Now I want to build a compose to check if the following is empty:

@{items('Apply_to_each_-_Certificates_2')?['EmailAddressNo2']}

And if so to only have one item inside the array, as follow:

"peoplePickerInput":"[ { \"Key\":\"@{items('Apply_to_each_-_Certificates_2')?['EmailAddressNo1']}\"}]"

So how I can do this inside compose and pass the output of the compose to the "Send HTTP request" action?

1 Answer 1

1

Try this:

  1. Add compose action before "Send an HTTP request to SharePoint" action and use expression in below format:

    if(empty(items('Apply_to_each_-_Certificates_2')?['EmailAddressNo2']), concat('[{ \"Key\":\"',items('Apply_to_each_-_Certificates_2')?['EmailAddressNo1'],'\"}]'), concat('[{ \"Key\":\"',items('Apply_to_each_-_Certificates_2')?['EmailAddressNo1'],'\"},{ \"Key\":\"',items('Apply_to_each_-_Certificates_2')?['EmailAddressNo2'],'\" }]'))
    
  2. Then use output of compose action as value for peoplePickerInput property in "Send an HTTP request to SharePoint" action

1
  • 1
    worked for me.... Commented May 14, 2023 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.