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:
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:
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:
Am I missing something in the Body of the HTTP request?
Please add file extension in File name of Create file action. IF it is excel use like .xlsx
Thanks
Hardesh
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.
Do one thing, remove your variable and type some text with extension then check.
Thanks
Hardesh
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.
Hi Aaron,
did you resolve the issue?
Best,
Adrian
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.
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.
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
Has anyone managed to get this working yet? Also the last tip didn't result in the file being corrupted.