Microsoft Flow - Block uploading Video files to a Sharepoint site - sharepoint

I am an owner of a Sharepoint site and want to make sure all members of the site don't upload video files. Since SP doesn't have the ability to filter out files by Type - I want to use Microsoft Flow to do this task.
So I have created this flow which triggers on creation of new file in Documents folder of my SP site. Then it runs a Condition, which checkes the property of "File content type" - if it starts with "video/" - then it should delete the file uploaded. It looks like this:
#startsWith(triggerOutputs()['headers']['Content-Type'], 'video/')
But when I run this Flow, I then get this error:
BadRequest. The request failed. Error code: 'InvalidRequestContent'. Error Message: 'The request content was invalid and could not be deserialized: 'Unexpected character encountered while parsing value: {. Path 'details', line 1, position 455.'.'.
What am I doing wrong?

Unfortunately there is no OOTB way to configure these settings yet. Your workaround to create a flow is just what I would have suggested. Ofcourse you can also still create a workflow that does that but why old fashioned if you already made your experience with flow.
This is a known issue and I would encourage you to vote for that feature here.
In OneDrive you can restrict certain file types from syncing using the poweshell:
Set-SPOTenantSyncClientRestriction -ExcludedFileExtensions "wmf;mp4;mkv"
For your flow I would suggest to make an extra step "get file content" and use the content type you get there for your filter instead of the one from your "triggerOutputs"

Related

python MSAL patch request "The OData request is not supported" marking message as read

my application has Mail.Read.Write permission for MS graph API and the application has restrict policy on exchange online . The restriction is for a security group and the mailbox folder i am trying to access is a member of that security group. get and post methods are working fine only problem is with patch . I need to mark some emails as read after processing them.
r2 = requests.patch(request_url2,
data=json.dumps(request_body2),
headers={'Content-Type': 'application/json','Authorization': 'Bearer ' + result['access_token']})
pastebin_url2 = r2.text
print("The pastebin URL is:%s"%pastebin_url2)
the same API works fine from graph explorer has anyone tried using python msal and requests...any help appreciated
Looks like the message Id changes after moving message to a different folder
so i changed my code to first mark the message as Read in Inbox and then move to a another folder instead of the other way around. I tried with ImmutableId but it also changes after moving message to different folder.

Microsoft Graph API - Copying SharePoint file - Item not found

I'm working with Graph API against Microsoft Teams team's SharePoint site.
I'm following the example on this page (https://learn.microsoft.com/en-us/graph/long-running-actions-overview?tabs=http) and have an issue. I'm able to query the location provided by the copy endpoint and get a "Completed" status that also provides a ResourceId. But I'm unable to use this resource id in any queries and only getting "Item not found".
Example of paths tried:
/drives/{driveId}/items/{resource-id-returned-from-monitor-url}
/groups/{groupId}/drive/items/{resource-id-returned-from-monitor-url}
The {driveID} is the driveId specified in the parentReference.DriveId in the copy file body.
I'm using the v1 Graph endpoint to get the file.
Btw, I can see the file fine in the correct folder within SharePoint.
Any ideas?
Regards,
Oskar
I wasn't using the DriveId supplied by the /education/***/setUpResourcesFolder Location header but rather the Drive of the class.
Fixed by using the driveId part of the Location URL.

Can i get the contents of historized sharepoint file with the logic app connector Get file Content (Sharepoint)?

I open succesfully files and grab the content of released sharepoint files.
Then i try to get an historized file and it fail.
this worked:
Siteaddress: https://domain.sharepoint.com/teams/Foldername
FilePath: /Freigegebene Dokumente/General/Filename
and this not:
Siteaddress: https://domain.sharepoint.com/teams/Foldername
FilePath: /_vti_history/1024/Freigegebene Dokumente/General/Filename
Is this possible or not?
Since you select the "Site Address" and "File Path" in the "Get file content using path" action and it can't get what you want, it seems the action can't implement this requirement.
As a workaround, maybe you can try with microsoft graph api to download the file in your _vti_history. Please refer to this document of the graph api. You can add a "HTTP" action in your logic app to call the graph api and download the file.

Get all items of a Sharepoint document library using Graph API

I'm trying to retrieve a document library by path using the Graph API and I'm not sure how to proceed.
The url to the library is for example the following:
https://hostname/sites/sitename/subsite/nameofdocumentlibrary/
I would like to have all the children through the Graph API. The issue: I know the document of the library but I don't know the ID of the library. It seems that it's possible to access it through the relative path but I'm not succeeding to it.
How do I do this?
My get url was the following:
/v1.0/sites/hostname:/sites/sitename/subsite/nameofdoccumentlibary/items
I'm always getting:
The provided path does not exist, or does not represent a site or UnknownError.
Any ideas ?
Try to use this:
GET https://graph.microsoft.com/v1.0/sites/{hostname},{spsite-id},{spweb-id}/lists/{list-id}
I don't check this in real life because I don't have SP Online. But it must working.
Use this link with SharePoint Graph API.
To get site id (site collection) you can go to your site collection and browse this endpoint:
https://hostname/sites/sitename/_api/site?$select=Id
To get web id (subsite) you can go to your subsite and browse this endpoint:
https://hostname/sites/sitename/subsite/_api/web?$select=Id
To get library Id you can just open Document Library Settings page. URL have library ID. You can transform it to real guid. Like this:
/_layouts/15/listedit.aspx?List=%7B603D7FA3-C801-46EB-A044-421234452901%7D
Must transformed to:
603D7FA3-C801-46EB-A044-421234452901
Following your feedback, I could now retrieve the document library using the display name (not the path in the url).
This is my request:
https://graph.microsoft.com/v1.0/sites/fullsubsiteid/lists/69369/items
69369 is my display Name here.
I can also use:
https://graph.microsoft.com/v1.0/sites/fullsubsiteid/lists/69369/drive
Now the first request, is returning an empty value array, while there is a "Documents" folder in the document library. How could I retrieve all folders/files etc in this document library? How can I use relative path?
Tx!

Uploading a file to SharePoint copyintoitems throws error

I am uploading files to SharePoint using the API Copy.CopyIntoItems. The upload works when the destination url is given as "http://sharepointserver/sitename". However, when the url is given with the domain name, like
"http://sharepointserver.domain/sitename", then the CopyIntoItems API call fails, and the error returned is "Object reference not set to an instance of an object".
Any idea on why there is a strange behavior when the url changes?
You can not use the url with the domain name, like "http://sharepointserver.domain/sitename" for Copying item
The following answer on SO links to a thread on MSDN, which explains in detail why this behaviour occurs: https://stackoverflow.com/a/2692212/274354
Link to the MSDN thread:
CopyIntoItems errors when using destination URI with FQDN

Resources