cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Patron
Post Patron

Extract JSON from a SharePoint List

Hello Community,

 

I need to build a flow where I can extract data from a SharePoint list, but the information is in JSON

We have various information that is captured in the JSON for holidays, i.e. cancelled, adjustments, leave request

 

I've not done anything like this before and I would like to extract this information from SharePoint and potentially put it into another SharePoint list or send via email as I've had a request to get a summary of a teams holiday.

 

Can anyone help me please with Screenshots on how I can achieve this?

Screenshot 2020-10-21 120754.png

This is the information I want to extract

mainly start date, end date, comment and units (no of days taken)

 

Thank you in advance for any help / screen shots provided

Kind regards

Claire

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Super User II
Super User II

Hello @ClaireAllen 

You could parse the JSON value using the "Parse JSON" action, where the schema should be generated with some sample data like the one you shared:

json_generate_from.png

 

The generated schema is this one:

{
    "type": "object",
    "properties": {
        "start": {
            "type": "string"
        },
        "end": {
            "type": "string"
        },
        "comment": {
            "type": "string"
        },
        "units": {
            "type": "string"
        },
        "GUID": {
            "type": "string"
        },
        "Type": {
            "type": "string"
        }
    }
}

 

In this case, we parse the JSON value stored in the "Title" column, and after that, we can access the values of the json data:

parse_json_2.png

 

Hope it helps!

Ferran

 

 

 

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

View solution in original post

Highlighted

The issue you are running into is because the Generate from sample creates a schema where all the values are considered "string".  The problem is that when running the flow some of those values may be missing (null).  To fix it edit the JSON schema created from the sample data by changing the 

 "type": {
          "type": "string"
         }

to 

 "type": {
          "type": ["string", "null"]
         }

 This will allow for that property to be null.  You may also need to edit the required field list at the bottom of the schema to remove non-required fields.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

13 REPLIES 13
Highlighted
Memorable Member
Memorable Member

Use the Get Items from SharePoint action in Flow and then use the "Parse JSON" action against the value retrieved from the JSON column.

 

That should give you the data you are after.

Highlighted
Super User II
Super User II

Hello @ClaireAllen 

You could parse the JSON value using the "Parse JSON" action, where the schema should be generated with some sample data like the one you shared:

json_generate_from.png

 

The generated schema is this one:

{
    "type": "object",
    "properties": {
        "start": {
            "type": "string"
        },
        "end": {
            "type": "string"
        },
        "comment": {
            "type": "string"
        },
        "units": {
            "type": "string"
        },
        "GUID": {
            "type": "string"
        },
        "Type": {
            "type": "string"
        }
    }
}

 

In this case, we parse the JSON value stored in the "Title" column, and after that, we can access the values of the json data:

parse_json_2.png

 

Hope it helps!

Ferran

 

 

 

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

View solution in original post

Highlighted

Hello @fchopo ,

Thank you for the information and screen shots, it really does help,

So I built the flow, but it does not seem to be the same, my Parse JSON are all Types and yours shows as the information I am looking for, i.e. Start Date, End Date etc

Step 1.pngParse JSON.png

This is how the Parse JSON is configured

{
    "type""object",
    "properties": {
        "type": {
            "type""string"
        },
        "properties": {
            "type""object",
            "properties": {
                "start": {
                    "type""object",
                    "properties": {
                        "type": {
                            "type""string"
                        }
                    }
                },
                "end": {
                    "type""object",
                    "properties": {
                        "type": {
                            "type""string"
                        }
                    }
                },
                "comment": {
                    "type""object",
                    "properties": {
                        "type": {
                            "type""string"
                        }
                    }
                },
                "units": {
                    "type""object",
                    "properties": {
                        "type": {
                            "type""string"
                        }
                    }
                },
                "GUID": {
                    "type""object",
                    "properties": {
                        "type": {
                            "type""string"
                        }
                    }
                },
                "Type": {
                    "type""object",
                    "properties": {
                        "type": {
                            "type""string"
                        }
                    }
                }
            }
        }
    }
}

Create Item.png

The flow ran, but then I got an error

 

Error Details.png

 

If you are able to help where I went wrong, it would be really appreciated,

Thanks again for the screen shots, as I felt I actually got somewhere

Kind regards

Claire

Highlighted

The issue you are running into is because the Generate from sample creates a schema where all the values are considered "string".  The problem is that when running the flow some of those values may be missing (null).  To fix it edit the JSON schema created from the sample data by changing the 

 "type": {
          "type": "string"
         }

to 

 "type": {
          "type": ["string", "null"]
         }

 This will allow for that property to be null.  You may also need to edit the required field list at the bottom of the schema to remove non-required fields.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Highlighted

Hello @Pstork1 

Thank you for the information, I tried that and received an error message to enter valid JSON

 

Kind regards

Claire

Highlighted

Hi @ClaireAllen 

Please, apply the solution by @Pstork1 to all the fields in the schema. It seems that some fields might have no value, and the Parse JSON action expects all of them to be informed. It should be something like this:

 

{
    "type": "object",
    "properties": {
        "start": {
            "type": ["string", "null"]
        },
        "end": {
            "type": ["string", "null"]
        },
        "comment": {
            "type": ["string", "null"]
        },
        "units": {
            "type": ["string", "null"]
        },
        "GUID": {
            "type": ["string", "null"]
        },
        "Type": {
            "type": ["string", "null"]
        }
    }
}

 

Hope it helps!

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
Highlighted

Can you show us the edited schema and the error message?



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Highlighted

Hello @Pstork1 , @fchopo 

 

I've updated the Schema as mentioned

Parse JSON.png

{
    "type""object",
    "properties": {
        "start": {
            "type": [
                "string",
                "null"
            ]
        },
        "end": {
            "type": [
                "string",
                "null"
            ]
        },
        "comment": {
            "type": [
                "string",
                "null"
            ]
        },
        "units": {
            "type": [
                "string",
                "null"
            ]
        },
        "GUID": {
            "type": [
                "string",
                "null"
            ]
        },
        "Type": {
            "type": [
                "string",
                "null"
            ]
        }
    }
}
 
But I still get an error message
Error details as requested
Error Details.png
 
Thank you for your assistance,
Kind regards
Claire
 
Highlighted

Hello @ClaireAllen 

By the screen captures you shared, it seems that the "approval JSON" column has different fields and values, so the structure is not always the same. For example, in a row there's a field called "comment", but in another one, this field is not provided.

 

comment.png

 

In order to work, the JSON structure should be always the same.

Hope it helps!

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
Highlighted

Thank you @fchopo 

That is the case with my data,

 

Thank you for your support

Regards

Claire

Highlighted

Your screenshot shows a successful loop.  Could you click on the next failed link and show us the output from a failed loop.  I suspect you are getting some loops where the Content itself is a null record.  you may have to add a filter array prior to starting the loop to remove those records.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Highlighted

Hello @Pstork1 , @fchopo 

 

Please see screen shot of the failed action

Error 31.png

Kind regards

Claire

Highlighted

Unfortunately, that screenshot doesn't really tell us anything other than that the Parse JSON action failed.  For Troubleshooting purposes please add a Compose step just above the Parse JSON inside the loop.  Add the content that you are feeding into the Parse Json.  That way we can see what the input of the parse JSON is.  That should help us figure out why that particular loop failed.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (12,971)