power-automate

Why doesn't the "Get file content" action get the file contents?


Creating a flow in Power Automate:

  1. New Step
  2. Choose the OneDrive "Get file content" action
  3. File = /Documents/Folder/File.json
  4. Infer Content Type = Yes
  5. New Step
  6. Choose the Data Operation "Parse JSON" action
  7. Generate from Sample
  8. Paste the file contents
  9. Done

When I test the flow, the "Parse JSON" step fails with

BadRequest. The property 'content' must be of type JSON in the 'ParseJson' action inputs, but was of type 'application/octet-stream'.

Looking at the output of the "Get file content" step

{"statusCode":200,"headers":{"Cache-Control":"no-cache","Pragma":"no-cache","Accept-Ranges":"bytes","ETag":...
,"Content-Disposition":"attachment; filename=\"File.json\""},"body":{"$con...

That is not my file content. It looks like the "file content" from OneDrive is an HTTP response.

What's going on here? What's the trick to use the content of a JSON file from OneDrive in Power Automate? The file is about 25 MB. Is there a size limit for JSON files for either OneDrive or Power Automate?


Solution

  • Pretty much every action that’s made to another service uses HTTP as the mechanism for doing so, hence why you see a HTTP response.

    You haven’t shown the entire output but I’m 99% sure you have the content in a base64 format which is contained in the $content property in the response. That’s pretty much confirmed by the error you’re getting.

    You need to convert that to regular text using the base64ToString function in a compose step or within your Parse JSON step.

    https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#base64ToString

    Alternatively, adjust the switch for inferring the content type and see if that gives you what you want. If not, revert to my original approach.