In Power Automate, each action expects data in a specific data type (e.g., text, number, boolean, array, or object). If an action receives data in the wrong format, it may fail with the following error:
“Invalid data type – The data type passed to the action does not match the expected type.”
This issue commonly arises when working with dynamic content, variables, or API responses that return unexpected formats.
2. Causes of “Invalid Data Type” Error
Several factors can trigger this error:
- Mismatched Data Type – The action expects a number but receives a string (e.g.,
"123"
instead of123
). - Null or Empty Values – The action requires a value, but the field is empty or null.
- Incorrect JSON Parsing – A JSON object or array is incorrectly formatted or not parsed before use.
- Unexpected API Response Format – The response data is in a different format than expected.
- Dynamic Content Issues – A previous step outputs the wrong type, such as a boolean instead of text.
- Array vs. Single Value Mismatch – An action expects a single item but receives an array.
- Expression or Variable Type Issues – Power Automate functions return an unexpected type.
- Inconsistent Formatting in Excel/SharePoint – Data types differ between source and destination.
3. Step-by-Step Troubleshooting Guide
Step 1: Identify the Failing Action
- Open Power Automate (https://flow.microsoft.com).
- Go to My Flows and select the affected flow.
- Click Run History and locate the failed run.
- Expand the failed action and review the Inputs and Outputs sections.
Solution:
- Look at what data type was expected vs. what was actually received.
Step 2: Check Data Type in Dynamic Content
Power Automate actions often rely on dynamic content from previous steps. If an action fails due to a type mismatch, the input field may contain unexpected data.
Solution:
- In the failed action, check the Inputs section.
- If the data type looks incorrect, go back to the step where the data originates.
- Use the “Compose” action before the failing step to inspect the actual value.
Example:
- If a field expects a number but receives
"45"
(a string), convert it usingint()
.
Step 3: Convert Data Type Using Expressions
If an action expects a specific data type, use Power Automate expressions to convert it.
Common Conversions:
Expected Type | Expression |
---|---|
String → Number | int(variables('yourVariable')) |
Number → String | string(variables('yourVariable')) |
Boolean → String | if(variables('yourVariable'), 'true', 'false') |
Date → String | formatDateTime(utcNow(), 'yyyy-MM-dd') |
String → Date | parseDateTime('2024-03-09', 'yyyy-MM-dd') |
Array → String | join(variables('yourArray'), ', ') |
Example:
- If an API returns
"100"
(as a string) but a number is required, convert it using: plaintextCopyEditint(outputs('PreviousStep')?['body/value'])
Step 4: Handle Null or Empty Values
If a required field is missing, the action might fail due to a null
value.
Solution:
- Use
coalesce()
to provide a default value:coalesce(variables('yourVariable'), 0)
Example:
- If a SharePoint field is empty, the flow might break. Use
coalesce()
to replacenull
with a default value.
Step 5: Validate JSON Parsing
If working with JSON data, ensure the structure matches what the action expects.
Solution:
- Use “Parse JSON” to validate the structure before using the data.
- If the action expects a single value but receives an array, extract the first value using:
outputs('Parse_JSON')?['body'][0]
Example:
- If an API returns:
{ "users": [ { "name": "Alice" }, { "name": "Bob" } ] }
But the flow expects just one user, use: plaintextCopyEditoutputs('Parse_JSON')?['body']['users'][0]['name']
Step 6: Check API Responses for Unexpected Formats
Sometimes APIs return unexpected data types.
Solution:
- Use “Compose” to inspect API responses before using them.
- If an API returns
"null"
instead of{}
, handle it withcoalesce()
.
Example:
- If an API sometimes returns
{"value": null}
, ensure your flow checks fornull
before processing.
Step 7: Fix Array vs. Single Value Issues
Some actions expect a single value but receive an array instead.
Solution:
- Use
first()
to extract the first item: plaintextCopyEditfirst(outputs('PreviousStep')?['body'])
- If the action expects an array, ensure the input is wrapped in square brackets
[ ]
.
Example:
- If an action expects
"email": "user@example.com"
but receives"email": ["user@example.com"]
, use: plaintextCopyEditfirst(outputs('PreviousStep')?['body']['email'])
Step 8: Ensure Excel/SharePoint Column Types Match
If working with Excel, SharePoint, or Dataverse, column types must match the expected format.
Solution:
- Open the data source (Excel, SharePoint, etc.).
- Check the column type (e.g., Text, Number, Date).
- Ensure that Power Automate sends data in the correct format.
Example:
- If a SharePoint “Number” column receives
"123"
(string), convert it using: plaintextCopyEditint(variables('YourVariable'))
4. Preventative Measures
To prevent “Invalid Data Type” errors in the future:
✔ Always inspect dynamic content before using it in actions.
✔ Use the “Compose” action to check variable contents before processing.
✔ Ensure JSON data is properly parsed before extracting values.
✔ Use Power Automate expressions to convert data types where needed.
✔ Check API responses for unexpected formats before using them.
✔ Validate SharePoint, Excel, and Dataverse column types before sending data.