cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate I
Advocate I

OneDrive for Business connector trigger returns base64 encoded strings for file name and file path

Hello,

I did notice that the OneDrive for Business connector returns base64 encoded strings for the fields 'file name' and 'file path' of the 'When a file is created' trigger. Is this expected behavior? I found no documentation about this and it makes debugging and monitoring flow runs in the past unnecessary complex by having to decode the string each time to find out which file triggered the flow.

Thank you!

Best Regards,

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

 

Hi @GoldenGecko ,

 

I think x-ms-file-name-encoded is not wrong.

Different triggers or actions will return different properties. This is more like a way to protect something, so some properties are encoded.

In addition, it seems that we cannot change this part of the code you provided. Except that the information filled in the fields can be changed, the other contents are already encapsulated. We cannot make any replacements for them.

 

As I mentioned in the last reply, we could directly use the expression to get the file path and file name. Like:

147.PNG

Hope this makes sense.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Highlighted
Community Support
Community Support

 

Hi @GoldenGecko ,

 

It is expected behavior. You could check the expression of the corresponding dynamic content.

116.PNG

The return value of this field is encoded. You could configure Get file metadata action below the trigger to get the actual value of the File Path and Filename.

115.PNG

Besides, you could also consider using When a file is created (properties only) as the trigger, then you don’t need to add Get file metadata action.

 

I hope this makes sense and feel free to let me know if you have any other questions.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted

Hi @v-bacao-msft!

Thank you for your reply. You are right that on hovering the file name variable, it's called 'encoded' at the end, as you have shown in the screenshot. This is not mentioned in the documentation nor clear by reading the field name in the trigger ('file name'). That's a bit unlucky.

In my case I'm not able to use When a file is created (properties only) as I do need the binary content of the file too, not just the meta data/properties. I'm moving a file from OneDrive for Business to a SharePoint Online document library by creating a new file on the SharePoint and deleting the file on OneDrive afterwards.

So any solution to have a better debugging experience results in an increase of the complexity of the flow and thus an increased failure-likeliness by having to add more actions.

Best Regards,

Highlighted

 

Hi @GoldenGecko ,

 

As an alternative workaround, you could use the expression to get the file name and file path output from the trigger.

Remove –encoded to get the actual value of these properties.

Like:

triggerOutputs()['headers']['x-ms-file-path']
triggerOutputs()['headers']['x-ms-file-name']

You could get expression by clicking peek code, dose not contains @. Then remove –encoded and configure it in the expression editor.

122.PNG123.PNG124.PNG

 

Besides, if you want to improve the experience of this trigger, please consider posting your suggestion in the ideas forum so that it might be considered for future release:

https://powerusers.microsoft.com/t5/Power-Automate-Ideas/idb-p/MPAIdeas

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted

Hi @v-bacao-msft!

Thank you for your reply! At first I thought I can change the output of the trigger but that won't work. What I can do is to change the the variables in the actions and remove the encoded part. I think I did find something interesting, see this code of the SharePoint Online 'Create File' action in the line with the @base64ToString() function call:

 

{
    "inputs": {
        "host": {
            "connection": {
                "name": "@parameters('$connections')['shared_sharepointonline']['connectionId']"
            }
        },
        "method": "post",
        "body": "@triggerBody()",
        "path": "/datasets/@{encodeURIComponent(encodeURIComponent('<URL to SharePoint Online site>'))}/files",
        "queries": {
            "folderPath": "/<removed>",
            "name": "@base64ToString(triggerOutputs()['headers']['x-ms-file-name-encoded'])",
            "queryParametersSingleEncoded": true
        },
        "authentication": "@parameters('$authentication')"
    },
    "metadata": {
        "flowSystemMetadata": {
            "swaggerOperationId": "CreateFile"
        }
    }
}

 

How comes that the connector returns it as a base64 string just to decode it from base64 string to a regular string within the SharePoint action? I think this should be investigated. Even more interesting is the fact that if there's x-ms-file-name-encoded and x-ms-file-name, why is the wrong one used internally? That would prevent the useless base65 encoding and decoding process.

I appreciate your support!

Best Regards,

Highlighted

 

Hi @GoldenGecko ,

 

I think x-ms-file-name-encoded is not wrong.

Different triggers or actions will return different properties. This is more like a way to protect something, so some properties are encoded.

In addition, it seems that we cannot change this part of the code you provided. Except that the information filled in the fields can be changed, the other contents are already encapsulated. We cannot make any replacements for them.

 

As I mentioned in the last reply, we could directly use the expression to get the file path and file name. Like:

147.PNG

Hope this makes sense.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (9,749)