Logic App SharePoint File List action no longer associated the correct MediaType with a file.
Good Morning.
In our Logic App workflow, we have an action that retrieves a list of files from a SharePoint folder. The action outputs the details of each file as JSON, including the file name, size and media type.
The issue we are seeing is that the action is no longer returning the expected MediaType, also known as the MIME type. Nothing has ever changed in this workflow from our side, it has been working solid for the past year.
For a CSV file, the action previously returned a MediaType of text/csv. It is now returning application/vnd.ms-excel for the same type of CSV file. Although application/vnd.ms-excel is normally associated with Excel files, it can also be used by some systems for CSV files.
This suggests that either the SharePoint action is no longer identifying CSV files as text/csv, or the action that creates the file in SharePoint is no longer assigning the same media type as before.
Has anything changed in the SharePoint connector or file creation behaviour? Users started reporting this issue this week. Last week, the media type was still being returned as text/csv.
Thanks,
-
Rakesh Mishra 9,695 Reputation points • Microsoft External Staff • Moderator
Hello Justin,
Thank you for reaching out to the community!
The behavior you are seeing is related to how the underlying Microsoft Graph API handles file metadata. The Logic Apps SharePoint connector retrieves the file's
MediaType(MIME type) as reported by the Microsoft Graph/SharePoint service. Recently, the default server-side mapping for.csvfiles shifted fromtext/csvtoapplication/vnd.ms-excel.Because the
mimeTypeproperty in theDriveItem.fileresource is generated on the server, it will return what the server dictates regardless of how the file was initially created or uploaded.As stated in the official Microsoft Graph API documentation for the File resource type:
mimeType: The MIME type for the file. This is determined by logic on the server and might not be the value provided when the file was uploaded. Read-only.
Workaround / Resolution: To resolve this and ensure your existing Logic App workflow continues to function correctly, you can manually normalize the MIME type within the Logic App before processing the file.
- Add a For each loop after your "List files in folder" action to iterate over the retrieved files.
- Inside the loop, add a Condition action to check if the file name ends with
.csv(e.g.,@endsWith(item()?['Name'], '.csv')). - In the True branch, use a Compose or Set variable action to explicitly assign the value
text/csv. - In the False branch, retain the original value by assigning the original
MediaTypeoutput (e.g.,@item()?['MediaType']). - Pass the newly assigned or retained MIME type to your downstream actions instead of relying on the raw output from the SharePoint connector.
This approach will restore the
text/csvidentification your workflow expects without relying on the service's default metadata mapping.Hope this helps you get your workflow back in sync! Please let me know if you have further questions.
References:
-
Justin Graham 0 Reputation points
Hi Rakesh,
Thank you so much for your quick and detailed response. This has been very helpful. And you explained it well.
Your recommended solution lines up with the idea we where thinking of doing also so that's good to hear.
May I ask, (And this is okay if you don't have this info), if you do - have you go the release information from Microsoft Graph API where they made this change to changed default server-side mapping for
.csvfiles? Patch notes? - it would really help me.Thanks again,
J
Sign in to comment
