web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Getting a file content...
Power Automate
Answered

Getting a file content on MS Flow using C#

(0) ShareShare
ReportReport
Posted on by

Hello,

 

I was trying to get a file content from my one drive account and pass & read it on my API using custom connector.

Here is my flow I created:

Capture2.PNG

 

And here is my data models in my API:

 

Capture.PNG

 

However, as I run my MS flow, I got this error:

Capture3.PNG

 

As you can see that the error might be because my context's data type is a string but apparently the File Content passed by one drive connector is not a string but a binary (I tried to put a simple string instead of a File Content on my flow and it works). What would be the data type I can use in my API to be able to store the file content passed by the one drive connector? is this a right way to do this? or Is there a better way to do this?

 

Thanks Smiley Happy

Categories:
I have the same question (0)
  • v-yamao-msft Profile Picture
    on at

    Hi @Anonymous,

     

    If you are trying to transfer a binary file into a JSON string, you need to encode it. Please try to use base64 encoding, and your API will have to decode it. then you will use format with the value byte.

     

      file:

           descrption:File content

           type:string

           format:byte

     

    More details about registering and using Custom APIs, please check the docs at here:

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/register-custom-api

        

     

    Best regards,

    Mabel Mao

  • Verified answer
    Community Power Platform Member Profile Picture
    on at

    @v-yamao-msftThanks for the replay 🙂

     

    I finally found the solution. I thought when we get the File Content from API, it will return some kind of base64 string. But it turns out that it will return JSON file, which has 2 property ($content-type and $content). And $content is the one that has the encoded content. 

     

    So what I did was I pulled the file content to my API as JSON formatted file, get its $content property, and convert it with convert.FromBase64String 

  • deepakmsflow Profile Picture
    23 on at
    Hi, I have a question and I am new to MS flow, How did you got the template "Get File content using a path" I did a search in the Templates,but I couldn't find,
  • CurtisJohnson89 Profile Picture
    14 on at

    Hey deepakmsflow

     

    you should probably start a new post for this question rather than tagging on to this post. If you search 'onedrive' then it gives you all the actions, you might be looking in the trigger section rather than the action section. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
trice602 Profile Picture

trice602 378 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 305 Super User 2025 Season 2

#3
Expiscornovus Profile Picture

Expiscornovus 155 Most Valuable Professional

Last 30 days Overall leaderboard