I have the following output from a GraphAPI call, of which I cant work out a way to extract the groupTypes and ID. Could someone lend me some guidence please
{
"statusCode": 200,
"headers": {
"Transfer-Encoding": "chunked",
"Vary": "Accept-Encoding",
"Strict-Transport-Security": "max-age=31536000",
"request-id": "1f9171fa-6c37-4877-9a7e-a61da01a929e",
"client-request-id": "1f9171fa-6c37-4877-8a7e-a61da02a929e",
"x-ms-ags-diagnostic": "{\"ServerInfo\":{\"DataCenter\":\"Australia Southeast\",\"Slice\":\"E\",\"Ring\":\"4\",\"ScaleUnit\":\"002\",\"RoleInstance\":\"ML1PEPF00004B03\"}}",
"x-ms-resource-unit": "1",
"OData-Version": "4.0",
"Cache-Control": "no-cache",
"Date": "Sun, 29 May 2022 02:26:02 GMT",
"Content-Type": "application/json; odata.metadata=minimal; odata.streaming=true; IEEE754Compatible=false; charset=utf-8",
"Content-Length": "445"
},
"body": {
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#directoryObjects(groupTypes,id)",
"value": [
{
"@odata.type": "#microsoft.graph.group",
"groupTypes": [
"DynamicMembership"
],
"id": "badc0e9e-d736-4534-b2c2-7aed3280a035"
},
{
"@odata.type": "#microsoft.graph.group",
"groupTypes": [
"Unified"
],
"id": "14a7c19e-db29-4e5c-82ec-657686b5f27d"
},
{
"@odata.type": "#microsoft.graph.group",
"groupTypes": [
"Unified"
],
"id": "1b8d728a-bf51-4ddd-b167-9e945f734d77"
}
]
}
}
Solved! Go to Solution.
@eliotcole thank you for taking the time to reply.
It would be interesting to see the function syntax in your SELECT FROM field please
OK, it's not really relevant what I used (because I put your result in a Compose action! 😅), it's relevant what you use to get the code that you listed.
So ... let us assume that the name of your Graph API call is just the standard one and you haven't renamed it. Then your From field would look like this:
body('Send_an_HTTP_request')?['body/value']
Or you could use this:
body('Send_an_HTTP_request')?['body']?['value']
Either should pull that array that you have there.
Hi, @LukePWilkins , have you taken a look at some of the recommendations on the side there?
This has come up a few times in the past week and I reckon you'd probably find an easily bent solution there. 👍 🙂
Anyway, here you can simple do a select on the body/value array, and create a key of Group Ids, then in the value side put the expression:
item()?['groupTypes']
This will provide each array as is.
If you're confident that each one only has one group inside it (ie. it's checked prior to entry), then you can use:
item()?['groupTypes'][0]
That will pull the first value from the groupTypes array into that value field.
If you only need it for a singular case, that's fine, if you want to manipulate the original input, then you can simply make a compose after you've generated your new value array, and call the original inside a setProperty() function, setting the value property to your newly generated value set. 🙂
If you wanted to be even cleverer you could use an if() statement to set it to a singular value for just one, or the array for more, or even a join() of the array if you still want a singular value.
if(
greater(
length(
item()?['groupTypes']
),
1
),
item()?['groupTypes'],
item()?['groupTypes'][0]
)
if(
greater(
length(
item()?['groupTypes']
),
1
),
join(
item()?['groupTypes'],
','
),
item()?['groupTypes'][0]
)
With a boolean variable choosing between array/string 😅:
if(
greater(
length(
item()?['groupTypes']
),
1
),
if(
variables('stringPleaseVAR'),
join(
item()?['groupTypes'],
','
),
item()?['groupTypes']
),
item()?['groupTypes'][0]
)
@eliotcole thank you for taking the time to reply.
It would be interesting to see the function syntax in your SELECT FROM field please
OK, it's not really relevant what I used (because I put your result in a Compose action! 😅), it's relevant what you use to get the code that you listed.
So ... let us assume that the name of your Graph API call is just the standard one and you haven't renamed it. Then your From field would look like this:
body('Send_an_HTTP_request')?['body/value']
Or you could use this:
body('Send_an_HTTP_request')?['body']?['value']
Either should pull that array that you have there.
Hello, that has given me some good guidence.
Where the return was producing [ "Dynamic ' ] for example, I was able to use the JOIN action to clean it up and return the Dynamic wording as a string.
cheers for taking the time to reply
Nice one, mate.
If you select yours, or my, or both(!), answers as Solution it'll just close out the thread so folks can find it in the future as a solution to whatever they need it for.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Announcing a new way to share your feedback with the Power Automate Team.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
User | Count |
---|---|
73 | |
26 | |
20 | |
15 | |
15 |
User | Count |
---|---|
145 | |
44 | |
44 | |
34 | |
32 |