cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Radoslavov
Helper V
Helper V

Get arrays from custome connector

Hi All,

 

I have a custom connector that is working perfect, the problem that I'm facing is that I cannot get the properties from the outputs.

 

This is what my custom connector returns

"body": {
        "_embedded": {
            "attendeeParticipationResponses": [
                {
                    "registrantKey""5114028005263885579",
                    "sessionKey""24277491",
                    "email""user1@gmail.com",
                    "joinTime""2021-02-08T12:06:19Z",
                    "leaveTime""2021-02-08T12:08:30Z",
                    "attendanceTimeInSeconds"131,
                    "attendance": [
                        {
                            "joinTime""2021-02-08T12:06:19Z",
                            "leaveTime""2021-02-08T12:08:30Z"
                        }
                    ],
                    "firstName""User",
                    "lastName""Test"
                }
            ]
        },
        "page": {
            "size"20,
            "totalElements"1,
            "totalPages"1,
            "number"0
        }
    }
 
What I'm trying to achieve is for each attendeeParticipationResponses to have the option to use the "email" value, as I will be using it as a filter with CDS emailaddress1 eq 'attendeeemail'
 
I've tried to use Parse JSON
41.PNG
But i'm getting this error: The execution of template action 'Apply_to_each_2' failed: the result of the evaluation of 'foreach' expression '@outputs('Get_attendees_for_all_webinar_sessions')?['body']' is of type 'Object'. The result must be a valid array.
 
So the question is how to make it possible to get the properties from each result returned from Apply to each step so I can use it later on with other connectors (CSD, SPO, O365, etc)
 
Regards
Kiril
1 ACCEPTED SOLUTION

Accepted Solutions
Paulie78
Super User III
Super User III

I would do this:

2021-02-11_12-13-02.png

From:

outputs('Get_attendees_for_all_webinar_sessions')['body']

webinarKey:

item()['webinarKey']

organizerKey:

item()['organizerKey']

This will produce a neat JSON array, like this:

[
  {
    "webinarKey": "8423865868034504719",
    "organizerKey": 7990114028417116000
  },
  {
    "webinarKey": "6348927997217270275",
    "organizerKey": 7990114028417116000
  }
]

View solution in original post

11 REPLIES 11
tom_riha
Super User II
Super User II

Hello @Radoslavov ,

the error tells you that the expression 'outputs('Get_attendees_for_all_webinar_sessions')?['body']' that you use as the input of the 'Apply to each' is not an array, it can't loop through it.

Since it says it's an Object, you should use it as the input of 'Parse JSON' directly, without 'Apply to each'.



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]
Radoslavov
Helper V
Helper V

Hi @tom_riha , thanks for helping me out with this.

 

The Apply to each gets added automatically since there will be more than one record returned (Get_attendees_for_all_webinar_sessions). However now I'm getting this error message when running flow with the Parse JSON 

 

The execution of template action 'Apply_to_each_2' failed: the result of the evaluation of 'foreach' expression '@outputs('Get_attendees_for_all_webinar_sessions')?['body/attendeeParticipationResponses']' is of type 'Null'. The result must be a valid array.

Paulie78
Super User III
Super User III

I would just add a compose with the following expression:

outputs('Get_attendees_for_all_webinar_sessions')['body']['_embedded']['attendeeParticipationResponses']

That brings you directly to your array, and produces output like this:

[
  {
    "registrantKey": "5114028005263885579",
    "sessionKey": "24277491",
    "email": "user1@gmail.com",
    "joinTime": "2021-02-08T12:06:19Z",
    "leaveTime": "2021-02-08T12:08:30Z",
    "attendanceTimeInSeconds": 131,
    "attendance": [
      {
        "joinTime": "2021-02-08T12:06:19Z",
        "leaveTime": "2021-02-08T12:08:30Z"
      }
    ],
    "firstName": "User",
    "lastName": "Test"
  }
]

Which you can then easily loop through.

 

Radoslavov
Helper V
Helper V

Well..it worked, but the flow failed for some reason because it returns two outputs.

I'm not sure what they are two when there is only one attendee returned from Get Attendees step.

I think this is happening because of the Apply to Each, but the problem again is that from the List webinars step i actually only need to values

"body": [
        {
            "webinarKey""8423865868034504719",
            "times": [
                {
                    "startTime""2021-02-15T10:00:00Z",
                    "endTime""2021-02-15T11:00:00Z"
                }
            ],
            "numberOfRegistrants"3,
            "webinarID""705095475",
            "subject""CRM integration",
            "description""",
            "timeZone""Europe/Bucharest",
            "inSession"false,
            "organizerKey"7990114028417116000,
            "registrationUrl""https://attendee.gotowebinar.com/register/8423865868034504719"
        },
        {
            "webinarKey""6348927997217270275",
            "times": [
                {
                    "startTime""2021-08-03T12:53:46Z",
                    "endTime""2021-08-03T13:53:46Z"
                }
            ],
            "numberOfRegistrants"0,
            "webinarID""392801547",
            "subject""Sample Webinar",
            "description""Welcome! Please start registering by entering your name and email address.\nFor those who can’t attend our live session, we’ll provide a recording.\n\nDetails:\n- We will be using GoToWebinar.\n- You can join our session by using a Mac, PC or a mobile device.\n\nAgenda:\n- Welcome and introductions\n- Demonstration and questions",
            "timeZone""Europe/Bucharest",
            "inSession"false,
            "organizerKey"7990114028417116000,
            "registrationUrl""https://attendee.gotowebinar.com/register/6348927997217270275"
        }
    ]
}

to be able to get_attendees but when I add them from the output option of list webinars they are put into applying to each. 

1.PNG

Radoslavov_0-1613044672307.png

Perhaps if I can get only these two values webinarkey and organizerkey , this will not put the entire logic into application to each.

Paulie78
Super User III
Super User III

You can easily do that, but the JSON you have posted here is very different from the one above. Which one is accurate?

It is the last one I've posted, this is the JSON from List Webinars step containing details about the webinar, which later one I need to pass when getting the attendees.

 

Paulie78
Super User III
Super User III

I would do this:

2021-02-11_12-13-02.png

From:

outputs('Get_attendees_for_all_webinar_sessions')['body']

webinarKey:

item()['webinarKey']

organizerKey:

item()['organizerKey']

This will produce a neat JSON array, like this:

[
  {
    "webinarKey": "8423865868034504719",
    "organizerKey": 7990114028417116000
  },
  {
    "webinarKey": "6348927997217270275",
    "organizerKey": 7990114028417116000
  }
]

View solution in original post

That is great, the only thing that left is actually to get from here

2.PNG

the "email" value so I can use it inside Apply to each to search in CDS for existing Contact with this email address

It is in Apply to each since there will be always more than one attendee returned from the list of attendees.

1.PNG

Paulie78
Super User III
Super User III

so that would simply be item()['email'] inside of the apply each loop

Radoslavov
Helper V
Helper V

I have to say big..no HUGE thank you @Paulie78 

This was an extremely hard task for me, but again thanks to you, we''ve completed the process. I hope with time I will become better with these expressions and would help others like me in such situations. With practice comes experience 😊

Radoslavov_0-1613049097768.png

Thanks again.

Kiril

 

Paulie78
Super User III
Super User III

Thank you, my pleasure! 
When one teaches, two learn!

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MSFTBizAppsLaunchEvent

Experience what’s next for Power Virtual Agents

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Users online (36,575)