cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AnkitShah55
Advocate III
Advocate III

Initialize variable from JSON, need help

Hello,

 

I need to get "id" parameter as a variable(Initialize Variable) from following JSON output of MSFT Graph API. Please help.

"id": "AAMkADxxxxxxxxxxxxxxxxxxNgBGAAAAAAA4KpCwRxxxxxxxxxxxxxxxxxxxxxxxpQQYAAAAN60Axxxxxxxxxxxd4TL0Efpe__dRVAAK5zvX6AAA="

{
    "statusCode": 200,
    "headers": {
        "Transfer-Encoding": "chunked",
        "Vary": "Accept-Encoding",
        "Strict-Transport-Security": "max-age=31536000",
        "request-id": "954b8428-xxx-xxxx-xxxx-27152a497dee",
        "client-request-id": "954b8428-xxx-xxxx-xxxx-27152a497dee",
        "x-ms-ags-diagnostic": "{\"ServerInfo\":{\"DataCenter\":\"South India\",\"Slice\":\"E\",\"Ring\":\"3\",\"ScaleUnit\":\"000\",\"RoleInstance\":\"MA1PExxxxxx12F7\"}}",
        "Timing-Allow-Origin": "*",
        "x-ms-apihub-cached-response": "true",
        "Cache-Control": "private",
        "Date": "Tue, 23 Feb 2021 20:08:09 GMT",
        "Content-Type": "application/json; odata.metadata=minimal; odata.streaming=true; IEEE754Compatible=false; charset=utf-8",
        "Content-Length": "1463"
    },
    "body": {
        "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('1f020274-xxxx-xxxx-xxxx-8bc529c82f91')/mailFolders('SentItems')/messages(id,toRecipients,ccRecipients,from,importance,hasAttachments,subject,createdDateTime,receivedDateTime,internetMessageId,isRead,attachments(size,isInline,lastModifiedDateTime))",
        "value": [
            {
                "@odata.etag": "W/\"Cxxxxxxxxxxxzemcid4TL0Efpe++dRVAAK4f0SL\"",
                "id": "AAMkADxxxxxxxxxxxxxxxxxxNgBGAAAAAAA4KpCwRxxxxxxxxxxxxxxxxxxxxxxxpQQYAAAAN60Axxxxxxxxxxxd4TL0Efpe__dRVAAK5zvX6AAA=",
                "createdDateTime": "2021-02-23T19:39:38Z",
                "receivedDateTime": "2021-02-23T19:41:34Z",
                "hasAttachments": false,
                "internetMessageId": "<PN1PR01xxxxxxxxxxxxB88C1F8809@PN1PR0101MB1517.INDPRD01.PROD.OUTLOOK.COM>",
                "subject": "xxxxxxxxxxxxxxxxxxxxx",
                "importance": "normal",
                "isRead": true,
                "from": {
                    "emailAddress": {
                        "name": "Ankit Shah",
                        "address": "xxxxx@xxxxxxxxx.com"
                    }
                },
                "toRecipients": [
                    {
                        "emailAddress": {
                            "name": "xxx xxx",
                            "address": "xxxx.xxxx@xxxxxxxxxxx.com"
                        }
                    }
                ],
                "ccRecipients": [],
                "attachments": []
            }
        ],
        "@odata.nextLink": "https://graph.microsoft.com/v1.0/me/mailFolders('SentItems')/messages?%24select=Id%2cToRecipients%2cCcRecipients%2cFrom%2cImportance%2cHasAttachments%2cSubject%2cCreatedDateTime%2cReceivedDateTime%2cInternetMessageId%2cIsRead&%24expand=Attachments(%24Select%3dSize%2cIsInline%2cLastModifiedDateTime)&%24top=1&%24skip=1"
    }
}

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Paulie78
Super User
Super User

Use this expression:

outputs('JSON')['body']['value'][0]['id']

You will need to adjust it so that outputs('JSON') is changed to whatever you are getting that JSON from.

View solution in original post

5 REPLIES 5
PrasadAthalye
Community Champion
Community Champion

Can you use ParseJSON action and use the above JSON to generate Schema? Then use Compose and Id from ParseJSON action?

PrasadAthalye_1-1614118878502.png

 

PrasadAthalye_0-1614118848313.png

 

Please Like and Mark this as Answer if it resolves your Issue.

Power Automate Community
Paulie78
Super User
Super User

Use this expression:

outputs('JSON')['body']['value'][0]['id']

You will need to adjust it so that outputs('JSON') is changed to whatever you are getting that JSON from.

AnkitShah55
Advocate III
Advocate III

@Paulie78 Thanks, that expression helped me.

 

@PrasadAthalye Thank you, but I am getting error while using the same method you described, please see attached photo.

 

AnkitShah55_0-1614153170072.png

 

PrasadAthalye
Community Champion
Community Champion

So did your issue resolve with the solution @Paulie78 provided?

Please Like and Mark this as Answer if it resolves your Issue.

Power Automate Community

Helpful resources

Announcements
Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (4,063)