Dear readers of my blog, to close the week I will quickly post an experience I had this week. This week I received a request from a customer to upload an image on SharePoint by using PowerApps. There are plenty of blog posts on the internet about how to implement this. So I won’t explain the whole solution, but I would like to point out to you a curious thing that I have discovered.

The Problem

When we use a custom connector for Flow and PowerApps we could capture this Base64 by using the action ‘When an HTTP request is received’. In the past, it was enough to give this Base64 to the action ‘Create File’. However, this week I ran into an error message here.

The input you get without creating the object. Then the step automatically creates content-type: image/jpeg. Here I got an error message.

When we gave the Base64 string as the input to the action, the ‘File Content’ property was automatically assigned ‘application/octet-stream’ as Content-Type. As a result, my images were not visible in SharePoint. And this is where the search for a workable solution started.

The Solution

Thanks to a colleague we were able to find a solution to this problem internally. The solution is very simple, but not really obvious. That’s why I wanted to share this with you quickly.

The compose step where we’re going to declare the object.

The action now expects an object, instead of a Base64 string. We declare this object in a Compose action. Entering the Content-Type of the file wasn’t rocket science either. As we got this from the ‘ When an HTTP request is received’, we could get it from the body of the request. We gave this value in the ‘Compose’ action. The code looks like this:

{

“$content-type”:”triggerMultipartBody()”,

“$content”:”triggerMultipartBody()”

}

Then we give the output of the compose step to the ‘Create File’ action.

Now we can see our images or documents in SharePoint! As a control, I’ll give you the output of the action after it’s been run. The output looks like this:

Note: It is important that the Content-Type is no longer equal to “application/octet-stream”.

Important! This way of working is accompanied by a custom connector that we wrote for PowerApps and Flow to forward this document. How to implement this can be seen in the blog below.
https://repointtechnologies.com/saving-images-from-powerapps-to-sharepoint/

Tip!

If you don’t use a custom connector for Flow and PowerApps, there is a hack I discovered this week. Our customer did not have premium licenses for Flow/PowerApps so I was allowed to look for an alternative. Thanks to this blog post I was able to avoid this: http://johnliu.net/blog/2019/4/flowninja-hack-87-lock-microsoft-flow-powerapps-trigger-to-upload-images-to-sharepoint-with-ease. Thumb up for this post, it helped me a lot.

I hope you have an answer now if you also run on this error message! Have a good weekend and see you at the next post!