Sharepoint Site Download a file Using Microsoft Graph 1.0 - sharepoint

What is wrong with this:
https://graph.microsoft.com/v1.0/sites/insuriasa.sharepoint.com:/Sites/IFS:/drive/root/children
At the end of the day I want to be able to download this:
https://graph.microsoft.com/v1.0/sites/insuriasa.sharepoint.com:/Sites/IFS:/drive/root:/Std Forms/Discovery Invest/Servicing/change_of_contribution_form_retirement_annuity_plan.pdf

If you want to download the file content in a web application you should do a GET call on the item with ?select=#content.downloadUrl parameter. In the response you will get a pre-authenticated url in the property '#microsoft.graph.downloadUrl' on that you can do a get call without passing any extra authentication header to download the file.
If you are using in native clients then this Download Endpoint should work fine.

Related

Shopware 6 call api from backend

I am making a new backend page where you should be able to download an export.
I already got the the route and the export working. If I call my export action from curl with sw-access-key I get my download: store-api/v3/_action/orderer-export/77f40024cfd448d9a90063a75dc9fb2e
How do I make the download link with auth?
Update
I added a service and created it like:
vendor/shopware/administration/Resources/app/administration/src/module/sw-import-export/service/importExport.service.js
Also changed store-api to api in my DownloadRoute.php: #RouteScope(scopes={"api"})
Now I can use this new service to call my API and the the file contents as response. Still no download.
Looking at \Shopware\Core\Content\ImportExport\Controller\ImportExportActionController::download I finally got it.
Simply add defaults={"auth_required"=false} to your route:
#Route("/api/v{version}/_action/import-export/file/download", name="api.action.import_export.file.download", defaults={"auth_required"=false}, methods={"GET"})
Security Warning: If your download contains non public information you need to add a secure token or download link. Otherwise your download is free for anyone. Shopwares own ImportExport generates download links with a token. Have a look there.

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.

how to download references from task details in ms graph?

how to download references from task details in ms graph?
I have the following reference from a task detail (plannerTaskDetails resource type):
https://my_domain.sharepoint.com/sites/HR2/Shared Documents/2.csv?web=1
and I want to download the file but I get:
'401 UNAUTHORIZED'
I have the following delegated permissions:
https://graph.microsoft.com/Files.Read.All
https://graph.microsoft.com/Group.Read.All
https://graph.microsoft.com/Sites.Read.All
I do not know if I have to add another permission. Any help is appreciated.
The actual value of the reference is 'https%3A//my_domain%2Esharepoint%2Ecom/sites/HR2/Shared Documents/2%2Ecsv?web=1' to get the url I have used:
from urllib.parse import unquote
url = 'https%3A//my_domain%2Esharepoint%2Ecom/sites/HR2/Shared Documents/2%2Ecsv?web=1'
sp_url = unquote(url)
sp_url
# 'https://my_domain.sharepoint.com/sites/HR2/Shared Documents/2.csv?web=1'
If I put the URL in a browser where I'm logged in I can download the file.
You can't use this url format to download the file with Microsoft Graph. The access token is for Microsoft Graph but your url is for https://my_domain.sharepoint.com.
Please refer to Download a file.
You should use GET https://graph.microsoft.com/sites/{siteId}/drive/root:/{item-path}:/content.
It will return a 302 Found response redirecting to a pre-authenticated download URL for the file. This is the same URL available through the #microsoft.graph.downloadUrl property on the DriveItem.
Then you can use this download url to download the file.
But based on my latest test, /content doesn't work for me. I'm not sure if it works for you. So there is another method here.
In your case, I assume that HR2 is a subsite under my_domain.sharepoint.com.
Then the real requests should be:
Call GET https://graph.microsoft.com/v1.0/sites/my_domain.sharepoint.com/sites to list the subsites and find the id of "HR2".
Call GET https://graph.microsoft.com/v1.0/sites/{id of "HR2"}/drive/root:/2.csv.
In the response, there is a #microsoft.graph.downloadUrl property. You can directly use that url to download the file.
If HR2 is another site collection, the requests should be:
Call GET https://graph.microsoft.com/v1.0/sites/my_domain.sharepoint.com:/sites/HR2 to get the id of "HR2".
The subsequent steps are the same as subsite.

instagram feed on website

I'm trying to display an Instagram feed on my website. I am not familiar with server side scripts. The explanations I have read go over my head.
I have managed to get an access key through Instagram but I don't know how to proceed.
I also tried the instructions from a video "How to implement an Instagram Feed in PHP without using the Instagram API"
For that, my php file works, displays the feed but I don't understand how to make it appear on my html page.
I'd be happy to make either method work.
In your HTML you should include a JavaScript 'script' element where you do something called an AJAX Request. The request will access the PHP file that produces the Instagram feed. ECHO the result from the PHP file and it will be returned into the DATA variable in the AJAX request. The request looks roughly like this:
$.ajax({
method: ‘POST or GET, most likely POST’,
url: ‘not always an actual url, this is the path to your PHP file’,
success: function(data) {
//php file returns into variable ‘data’
//display the feed within this function
}
});
The result from the PHP file should be echo’d back in JSON notation, if it isn’t, just add this to end of PHP the file:
$whatever = json_encode($your_result);
echo $whatever; //this is still the feed, just encoded in JSON
And if you need to decode it for some reason, just do
json_decode($variable_to_decode);
There are other parameters you can use in the AJAX request, like if for instance you need access to certain variables in your PHP file, that currently only exist in your HTML document.
this was solved by saving the html as php. i don't know why that is but it worked

Get a weburl from Sharepoint Client Side Object Model

So let's say I have a full url into a sharepoint website.
In the past when I wanted to get the weburl and doc url, I used the "url to web url" method of the Front Page Server Extensions. (http://msdn.microsoft.com/en-us/library/ms460544.aspx).
So for example if you had a site at
http://webapp/site1/chidsite/a.doc
I want a method in CSOM that will return /site1/childsite as the weburl.
I see the Web.WebUrlFromPageUrlDirect() method in CSOM but I'm not sure I'm getting what I need back from it. In the Uri class I get back, would I use teh "AbsolutePath" property for the weburl?
What is the correct way to do this?
I also would like to get the docURL that is usually retrieved by a call to url to web url via frontpage extensions.
The fileurl will be the file location relative to the web site. So if the document is stored in the document library called "Documents", you will get a value of /Documents/file.ext.
Well, I've reverted to using the FrontPage extensions when doing URLToWebURL since I just wasn't sure what I was getting using CSOM methods. Though check the link below for answers I received elsewhere.
Information Pertaining to this issue

Resources