cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
IanNev
Frequent Visitor

Help with Microsoft Flow Parse JSON

I am feeding a JSON from Azure Automation Runbook to Microsoft Flow

 

I am getting an error:

'Unexpected token encountered when reading value for 'OdataType'. Expected StartObject, Boolean, got String. Path 'schema.properties.InvitedUser.properties.OdataType'.'.

My JSON schema looks like this:

https://gist.github.com/ian-nevda/c3cfc8aa177dcf0e9f6d999bebfce331

My original JSON that I am trying to feed to flow looks like this:

https://gist.github.com/ian-nevda/a691f07f206b9fe8fc0539f56034a2cf

 

As you can see in the original, in most cases the field "OdataType" is null. I tried defining it as "string" in the schema which doesn't appear to work.

 

I am not sure how to re-format my schema to make this work 😞

Any help at all is appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
IanNev
Frequent Visitor

I figured it out!

 

Seeing that the object never gets to flow made start thinking in the right direction.

 

Turns out I hadn't selected "Wait for Job" when creating the runbook job in Flow. Now the Flow waits for the job to complete before retrieving the results. 

 

You schema appears to have worked as well.

 

Thank you very much for your efforts, I will keep this post updated should I face any other issues.

View solution in original post

12 REPLIES 12
Jcook
Super User
Super User

Hello @IanNev 

 

Thank you for the JSON sample, I was able to get your Sample JSON to parse correctly.

What I did was, for all values that could be null, I removed the type. This allows the JSON to parse with any type.

 

Here is the Schema:

{
 "type": "object",
    "properties": {
        "Id": {
            "type": "string"
        },
        "InvitedUserDisplayName": {
            "type": "string"
        },
        "InvitedUserEmailAddress": {
            "type": "string"
        },
        "SendInvitationMessage": {
            "type": "boolean"
        },
        "InviteRedeemUrl": {
            "type": "string"
        },
        "InviteRedirectUrl": {
            "type": "string"
        },
        "InvitedUser": {
            "type": "object",
            "properties": {
                "Id": {
                    "type": "string"
                },
                "OdataType":{
                }
            }
        },
        "InvitedUserMessageInfo": {
            "type": "object",
            "properties": {
                "CcRecipients": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "CustomizedMessageBody": {

                },
                "MessageLanguage": {   
                }
            }
        },
        "InvitedUserType": {
            "type": "string"
        },
        "Status": {
            "type": "string"
        }
    }
}

 

 


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





IanNev
Frequent Visitor

Hello,

 

Thank you very much for your reply.

 

I've tried using your suggested schema but unfortunately ended up with this error

 

Unable to process template language expressions in action 'Parse_JSON' inputs at line '1' and column '2221': 'Required property 'content' expects a value but got null. Path ''.'.

 

I've confirmed that my latest runbook test completed successfully and generated the output JSON properly.

 

For reference, here is a screenshot of my flow configuration.

 

Screen Shot 2020-06-10 at 10.20.09 PM.png

 

Once again, any and all help is extremely appreciated.

 

Hi @IanNev 


I am a bit confused. In the screenshot you posted, you are using a a different schema than I provided.


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





IanNev
Frequent Visitor

Sorry for the confusion. The screenshot is outdated but the error I am getting comes out as result of using your schema.

 

Thank you,

 

Ian

Hi @IanNev 

 

Okay, thanks for clarifying.

 

The error:

Unable to process template language expressions in action 'Parse_JSON' inputs at line '1' and column '2221': 'Required property 'content' expects a value but got null. Path ''.'.

 

Means that the JSON that is being passed into the Parse JSON is empty/null

 

Would you be able to try and run again.

 

Post a updated screenshot of the Flows Runbook action so we know what is being passed in to the Parse JSON

 

 


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





IanNev
Frequent Visitor

Thank you. 

 

Here is the results of my latest Flow run

 

1.PNG

 

Here is the result of the latest runbook triggered by this Flow

 

2.png

 

 

@IanNev 

 

Would you be able to add a Compose action in between the Run book and Parse JSON.

 

Inside the Compose action put the Dynamic Content 'content' inside.

 

Again, I think it is weird that the Error is saying the JSON is empty.

If you want to check if Schema is the issue. You can put the schema as:

 

{}

 


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





IanNev
Frequent Visitor

Tried adding a compose action as per your recommendation. Both Input and Output fields return empty files. So I guess my runbook object never gets through to my Flow.

 

Perhaps the issue is with my Powershell code then?

 

My script is quite simple, here it is:

 

#send AzureAD invitation

$newuser = New-AzureADMSInvitation -InvitedUserEmailAddress $guestemail -InvitedUserDisplayName $displayname -InviteRedirectURL https://myapps.microsoft.com -SendInvitationMessage $true

#extract userid for further flow config

Write-Output $newuser | ConvertTo-Json
 

@IanNev 

How are you triggering the flow? Are you triggering manually? Or are you using the test button at the top right corner?


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





IanNev
Frequent Visitor

I am triggering it manually. Not a test run. I enter all the parameters I've defined and they get passed down to the runbook. I can confirm that my guest user invitation does get sent and that part of the flow is working. 

IanNev
Frequent Visitor

I figured it out!

 

Seeing that the object never gets to flow made start thinking in the right direction.

 

Turns out I hadn't selected "Wait for Job" when creating the runbook job in Flow. Now the Flow waits for the job to complete before retrieving the results. 

 

You schema appears to have worked as well.

 

Thank you very much for your efforts, I will keep this post updated should I face any other issues.

View solution in original post

@IanNev 

 

Awesome news!

 

If you could, please accept a solution once your initial problem has been solved and give thumbs up to any posts you found helpful  😊

This is to insure others with similar errors can find a solution quickly.

 

If you have any additional errors in the future. Please create a new post. Feel free to tag me if you want.

 

Thanks!


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (1,138)