cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AaronM-C
New Member

Parse JSON from a HTTP GET request

I'm working with a client that needs automatic reporting on per user licensing based on groups, this can be obtained manually but Automaticaly is causing me a head ache

 

So far I have designed a flow that pulls the users in a group from AAD and once its done that it checks each user against the MS graph   https://graph.microsoft.com/v1.0/users/@{items('Apply_to_each')?['id']}/licenseDetails

 

this element works fine, and Almost gives me what I need, the problem is it response in a JSON format with firstly allot more info than is needed but also in information that needs correlating.. (license type would appear as the below), this is a snip from the response. 

 

            "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "skuId": "71f21848-f89b-4aaa-a2dc-780c8e8aac5b",
            "skuPartNumber": "CPC_B_2C_8RAM_128GB",
            "servicePlans": [
                {
                    "servicePlanId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                    "servicePlanName": "M365_LIGHTHOUSE_PARTNER_PLAN1",
                    "provisioningStatus": "Success",
                    "appliesTo": "Company"
 
I have tried to use Parse JSON to allow me to retreieve the skuID and then using the below Schema but this fire out this error when I try 
 
InvalidJSON. The 'content' property of actions of type 'ParseJson' must be valid JSON. The provided value cannot be parsed: 'Unexpected character encountered while parsing value: L. Path '', line 0, position 0.'. 
 
{
    "type""object",
    "properties": {
        "@@odata.context": {
            "type""string"
        },
        "value": {
            "type""array",
            "items": {
                "type""object",
                "properties": {
                    "id": {
                        "type""string"
                    },
                    "skuId": {
                        "type""string"
                    },
                    "skuPartNumber": {
                        "type""string"
                    },
                    "servicePlans": {
                        "type""array",
                        "items": {
                            "type""object",
                            "properties": {
                                "servicePlanId": {
                                    "type""string"
                                },
                                "servicePlanName": {
                                    "type""string"
                                },
                                "provisioningStatus": {
                                    "type""string"
                                },
                                "appliesTo": {
                                    "type""string"
                                }
                            },
                            "required": [
                                "servicePlanId",
                                "servicePlanName",
                                "provisioningStatus",
                                "appliesTo"
                            ]
                        }
                    }
                },
                "required": [
                    "id",
                    "skuId",
                    "skuPartNumber",
                    "servicePlans"
                ]
            }
        }
    }
}
 
I need to first of all get the skuID and then I need to compare this against information available on https://learn.microsoft.com/en-us/azure/active-directory/enterprise-users/licensing-service-plan-ref... to get the license name but this PARSE JSON doesnt seem to play ball, probably a simple error but hoping any of you could help. 
4 REPLIES 4
VictorIvanidze
Community Champion
Community Champion

Hi @AaronM-C,

 

try to get skuID directly:

body('Send_an_HTTP_request_4')?['value'][0]?['skuId']

 

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.
VictorIvanidze
Community Champion
Community Champion

Hi @AaronM-C,

any comments? 

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.
AaronM-C
New Member

Unfortunately that didnt work, MS graph refused the body request
I managed to get a workaround though

AaronMC_0-1669899125828.png

 

AaronMC_1-1669899157375.png

AaronMC_2-1669899184163.png

 

 

 

VictorIvanidze
Community Champion
Community Champion

Hi @AaronM-C,

could you please confirm this works for you:

VictorIvanidze_0-1669899684893.png

 

 

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (3,567)