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

Create flow BadRequest error

Hi, 

I am trying to build a flow that -based on a list of site names- builds a flow for each site in my array if that flow is not yet created. 

I managed to get the template flow data with a "Get Flow" action, successfully checked if the wanted flow exists in the list of all flows, managed to manipulate my flow definition based on this article, however when I run the flow it comes back with a "BadRequest" and "Action 'Create_Flow' failed" when I do NOT add any connectionReferences. When I DO add connection references, it fails just the same but adding the connection references to the end of the inputs of the create flow action. 

 

You can find the inputs for the create flow action below. I have also attached the screenshot of the error I get upon running the flow. 

*I have changed the actual values of the environmentName, dataset, the table in the code below from the actual values in this snippet.

no connectionReferences create flowno connectionReferences create flow

 

 

 

{
    "host": {
        "connectionReferenceName": "shared_flowmanagement",
        "operationId": "CreateFlow"
    },
    "parameters": {
        "environmentName": "Default-~~~",
        "Flow/properties/displayName": "Support Log Emails",
        "Flow/properties/definition": {
            "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
            "contentVersion": "1.0.0.0",
            "parameters": {
                "$connections": {
                    "defaultValue": {},
                    "type": "Object"
                },
                "$authentication": {
                    "defaultValue": {},
                    "type": "SecureObject"
                }
            },
            "triggers": {
                "When_an_item_is_created": {
                    "recurrence": {
                        "frequency": "Minute",
                        "interval": 3
                    },
                    "splitOn": "@triggerOutputs()?['body/value']",
                    "type": "OpenApiConnection",
                    "inputs": {
                        "host": {
                            "apiId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline",
                            "connectionName": "shared_sharepointonline",
                            "operationId": "GetOnNewItems"
                        },
                        "parameters": {
                            "dataset": "https://[tenant].sharepoint.com/sites/[site]",
                            "table": "[tableid]"
                        },
                        "authentication": "@parameters('$authentication')"
                    }
                }
            },
            "actions": {
                "Condition": {
                    "actions": {
                        "Condition_2": {
                            "actions": {
                                "Send_an_email_(V2)": {
                                    "runAfter": {},
                                    "type": "OpenApiConnection",
                                    "inputs": {
                                        "host": {
                                            "apiId": "/providers/Microsoft.PowerApps/apis/shared_office365",
                                            "connectionName": "shared_office365",
                                            "operationId": "SendEmailV2"
                                        },
                                        "parameters": {
                                            "emailMessage/To": "@triggerOutputs()?['body/AssignedTo/Email']",
                                            "emailMessage/Subject": "Support Item @{triggerOutputs()?['body/ID']}",
                                            "emailMessage/Body": "<p>Support Item @{triggerOutputs()?['body/ID']} @{triggerOutputs()?['body/Title']} was assigned to you.</p>"
                                        },
                                        "authentication": "@parameters('$authentication')"
                                    }
                                }
                            },
                            "runAfter": {},
                            "expression": {
                                "not": {
                                    "equals": [
                                        "@triggerOutputs()?['body/AssignedTo/Email']",
                                        "@null"
                                    ]
                                }
                            },
                            "type": "If"
                        }
                    },
                    "runAfter": {},
                    "expression": {
                        "equals": [
                            "@triggerOutputs()?['body/{ContentType}/Name']",
                            "Issue"
                        ]
                    },
                    "type": "If"
                }
            }
        },
        "Flow/properties/state": "Started"
    }
}

 

 

Error upon create flowError upon create flow

 

1 REPLY 1
Cimares
Regular Visitor

Hi Yvette,

Thanks for following my article. Unfortunately that error is rather generic so I would recommend copying the flow definition from the failed Create Flow action and loading it into something like VSCode that will be able to validate the JSON that has been created. Invariably when create flow fails, it's due to the JSON being invalid in some form.

A lot of the issues I met when fixing that original problem that prompted the article, was down to encoding the right values in the JSON so the that new flow definition was protected from the flow that was creating it.

Also make sure that you collapse the Connection References to a single field when you add them. (Click on the little T symbol to the right of the field)

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (1,218)