i have a logic app in azure. i'm currently stuck in initialize expression variable after parse json. i want to catch "appId" parameter but all i get is null despite the fact that parse json giving an outout, so it seems that i I'm not expressing the right syntax.
this is my JSON output in parse JSON step
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#servicePrincipals",
"value": [
{
"id": "***********************",
"deletedDateTime": null,
"accountEnabled": true,
"alternativeNames": [],
"appDisplayName": "testapp",
"appDescription": null,
"appId": "******************************",
"applicationTemplateId": null,
"appOwnerOrganizationId": "****************************",
"appRoleAssignmentRequired": false,
"createdDateTime": "2024-06-23T10:24:17Z",
"description": null,
"disabledByMicrosoftStatus": null,
"displayName": "testapp",
"homepage": null,
"loginUrl": null,
"logoutUrl": null,
"notes": null,
"notificationEmailAddresses": [],
"preferredSingleSignOnMode": null,
"preferredTokenSigningKeyThumbprint": null,
"replyUrls": [],
"servicePrincipalNames": [
"********************************"
],
"servicePrincipalType": "Application",
"signInAudience": "AzureADMyOrg",
"tags": [
"HideApp",
"WindowsAzureActiveDirectoryIntegratedApp"
],
"tokenEncryptionKeyId": null,
"samlSingleSignOnSettings": null,
"addIns": [],
"appRoles": [],
"info": {
"logoUrl": null,
"marketingUrl": null,
"privacyStatementUrl": null,
"supportUrl": null,
"termsOfServiceUrl": null
},
"keyCredentials": [],
"oauth2PermissionScopes": [],
"passwordCredentials": [],
"resourceSpecificApplicationPermissions": [],
"verifiedPublisher": {
"displayName": null,
"verifiedPublisherId": null,
"addedDateTime": null
}
},
{
"id": "**********************8",
"deletedDateTime": null,
"accountEnabled": true,
"alternativeNames": [
"isExplicit=False",
"/subscriptions/******************************************/resourcegroups/Test-RG/providers/Microsoft.Logic/workflows/test"
],
"appDisplayName": null,
"appDescription": null,
"appId": "******************",
"applicationTemplateId": null,
"appOwnerOrganizationId": null,
"appRoleAssignmentRequired": false,
"createdDateTime": "2024-07-11T09:32:51Z",
"description": null,
"disabledByMicrosoftStatus": null,
"displayName": "testeldad",
"homepage": null,
"loginUrl": null,
"logoutUrl": null,
"notes": null,
"notificationEmailAddresses": [],
"preferredSingleSignOnMode": null,
"preferredTokenSigningKeyThumbprint": null,
"replyUrls": [],
"servicePrincipalNames": [
"***********************",
"https://identity.azure.net/*******************/**********************"
],
"servicePrincipalType": "ManagedIdentity",
"signInAudience": null,
"tags": [],
"tokenEncryptionKeyId": null,
"info": null,
"samlSingleSignOnSettings": null,
"addIns": [],
"appRoles": [],
"keyCredentials": [
{
"customKeyIdentifier": "*****************",
"displayName": "CN=**********************",
"endDateTime": "2024-10-09T09:27:00Z",
"key": null,
"keyId": "*********************",
"startDateTime": "2024-07-11T09:27:00Z",
"type": "AsymmetricX509Cert",
"usage": "Verify"
}
],
"oauth2PermissionScopes": [],
"passwordCredentials": [],
"resourceSpecificApplicationPermissions": [],
"verifiedPublisher": {
"displayName": null,
"verifiedPublisherId": null,
"addedDateTime": null
}
}
]
}
i tried using that syntax --> first(outputs('Parse_JSON')?['body/value'])['appId'] and many many more :)
I'm using "first" coz there is a few appId instances in the output so i want to catch the first part. (don't know if it's the right way)
To get the first appId, instead of first(outputs('Parse_JSON')?['body/value'])['appId']
you should use this:
body('Parse_JSON')?['value']?[0]?['appId']
Testing:
Update:
Parsing the JSON before extracting field values is, strictly speaking, not required. For example, you are receiving a JSON content in the output of the HTTP action:
You can get the appId value from there as follows:
body('HTTP')?['value']?[0]?['appId']