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 / Create file in SPO doc...
Power Automate
Unanswered

Create file in SPO document library using HTTP request

(0) ShareShare
ReportReport
Posted on by 148

I'm trying to build a flow that creates a file in a SharePoint document library using the Send an HTTP request to SharePoint action. I'm using this action because I want the document library to be dynamic, and the Create File action doesn't appear to allow that. 

 

My flow creates the file in the library without any errors, but when I attempt to open the file I see a message that the file isn't valid:

AaronRichardson_0-1601417257089.png

I decided to hard code a document library path and use the Create File action to compare the files once they're uploaded. This is the result:

AaronRichardson_1-1601417412329.png

 

The bottom file is created using the Create File action and opens just fine. The top file is quite a bit larger, which makes me think it isn't properly encoded. 

 

I'm pulling the file contents from PowerApps in base64 format as demonstrated here. Since both actions use the same data, I believe I'm missing something in the body of the HTTP request action. Here are the two actions:

AaronRichardson_2-1601417998181.png

 

Am I missing something in the Body of the HTTP request?

 

Categories:
I have the same question (0)
  • Hardesh15 Profile Picture
    7,087 Super User 2024 Season 1 on at

    @AaronRichardson 

     

    Please add file extension in File name of Create file action. IF it is excel use like .xlsx

     

    Thanks

    Hardesh

  • AaronRichardson Profile Picture
    148 on at

    Thanks, @Hardesh15. The file extension is already included in the variable as shown by the image of the two files that the flow created in SPO. Something else is happening to cause the file to not be created properly. 

  • Hardesh15 Profile Picture
    7,087 Super User 2024 Season 1 on at

    @AaronRichardson 

    Do one thing, remove your variable and type some text with extension then check.

    Thanks

    Hardesh

  • AaronRichardson Profile Picture
    148 on at

    I tried your suggestion. The outcome is the same, the file is not valid. Again, I believe this has to do with the encoding or something having to do with the format of the Body in the HTTP request.

  • AdrianGo Profile Picture
    4 on at

    Hi Aaron,

     

    did you resolve the issue?

    Best,

    Adrian

  • AaronRichardson Profile Picture
    148 on at

    @AdrianGo No, I was not able to resolve the issue.

  • illmatic Profile Picture
    169 on at

    Hi Aaron & @AdrianGo 

    You can successfully submit this request by changing your headers. 

    Accept: application/json; odata=nometadata,
    Content-Type: application/json; odata=nometadata

    When you set the odata to verbose, you have to provide the metadata and type in the body.

  • AdrianGo Profile Picture
    4 on at

    Hi Illmatic,

     

    the problem is not about submit the request, but with content of the file which is passed via variable. Variable changes encoding to UTF-8 I believe so the file content is broken.

  • liridonuka Profile Picture
    46 on at

    I would suggest to use payload data from Create file connector and there you will find body JSON which you can use in HTTP Request body 

     

    liridonuka_0-1635280274175.png

     

  • Christoph15 Profile Picture
    62 on at

    Has anyone managed to get this working yet? Also the last tip did result in the file being corrupted.

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…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard