Access File from sharepoint list using Microsoft Graph - sharepoint

I am able to access list with this URL https://graph.microsoft.com/v1.0/sites/collaboration.sharepoint.com,acg7dc07-275d-4d76-8f60-58ea3b489989,9cd9b335-0955-4af5-8a3b-1546fcdc728a/lists/9844ca7d-300c-43d9-8537-86e194de7203
But unable to access file item from here. Please can you provide graph query for this."children" element is not working

If you want to get SharePoint file with Graph API, you should take a reference to this:https://learn.microsoft.com/en-us/graph/api/resources/onedrive?view=graph-rest-1.0
Demo:
https://graph.microsoft.com/v1.0/sites/b57886ef-vvvv-4d56-ad29-27266638ac3b,b62d1450-8e6f-4be7-vvvv-f6600fd6cc14/drives/b!74Z4tSpMVk2tKScmZjisO1AULbZvjudLhKP2YA_WzBRoT2if-9ngRbwNEoecoTO3/root/children
https://graph.microsoft.com/v1.0/sites/b57886ef-vvvv-4d56-ad29-27266638ac3b,b62d1450-8e6f-4be7-vvvv-f6600fd6cc14/drives/b!74Z4tSpMVk2tKScmZjisO1AULbZvjudLhKP2YA_WzBRoT2if-9ngRbwNEoecoTO3/items/01ATCFPNRYOGQCUL46MZDI6LKDDX35NQPB/children

Related

How to get/download the uploaded files form Microsoft team using java sdk with microsoft graph API

I have Microsoft account with some groups and uploaded few documents on it.
I have authentication code to connect to MS team and call the Microsoft graph API in place and it is working fine I can access few of the Teams api like get list of groups. channels and user.
But my requirement is I want to download the uploaded file to any group or channel of the MS teams.
I am trying below API to access it
graphClient.teams("acebf8ec-ea79-45f5-9570-b8e0bcdeeaba").channels(
"19%3afd70e03ba2c24cd7bffac753149dc620%40thread.tacv2").filesFolder().
buildRequest().get();
InputStream stream = graphClient.customRequest("/groups/{group-id}/drive/items/{item-id}/content",
InputStream.class) .buildRequest() .get();
what will be the {item-id} here how we get the id, any API for this?
With help of these API I am unable to get the file uploaded on MS teams.
Please help me.
I am looking for the java code to achieve this.
Thank you!!
https://graph.microsoft.com/v1.0/groups/{group-id}/drive/root/children
gives you the list of driveitems. Each object has id which is noting but the itemid. Pick the id which you want to get the content for and use the same call as you said.
/groups/{group-id}/drive/items/{item-id}/content
You can test your graph API calls in Graph Explore as well.

Need help on searching a document form Sitepage in Sharepoint using Microsoft Graph

I am working on SharePoint Integration where i am able to success using Microsoft Graph Explorer for a Site search using Drive id.
Here is how i am able search for a Single Site:
https://graph.microsoft.com/v1.0/drives/b!I9A-JY94D0CQp-2TBvsUupBLMUF2SrJHp5VylC7DY8DpCdF-7uQ6NTp6t-MRD8/root/search(q='sharepoint')
With this i am able to get the details of the record 'Sharepoint'.
Now i am trying to search in SitePage where we have Documents added. Can anyone please help me the api to be used in Graph Explorer to get the correct result
I am able to SitePage id using
https://graph.microsoft.com/beta/sites/root/pages?$filter=name eq 'DevHome.aspx'
Your Approach is incorrect.
If you have to search the content of the document library added to a Site page, you need to query the doc library not the Site page.
Using Graph API you will not be able to search the content in the site page.

Add sharepoint custom field using Graph API

I want to upload my documents to my SharePoint site using Graph API. I followed the instruction in these posts and I'm able to upload my docs to Sharepoint site.
How to create SharePoint list item with Microsoft Graph API?
https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/driveitem_put_content
However, I want to update some values of uploaded documents in the Document Library items but I cannot find any document to do that. Please advise me in this situation.
Notice: I found the solution by this post.
How To Retrieve Custom Columns For DriveItems in MS Graph

Access External List from SharePoint Add-In using REST

I am using the SharePoint REST API inside an Add-In to access list data. When I query a "normal" list, I get results back. When I try to query an External List, I get a 401 error. I get the same error when I try to access the REST URL in the browser:
http://add-in-6f1ecc432fad91.myaddins.com/sites/development/_api/lists/getbytitle('TestExternalList')/items
When I try to access it outside the app it works fine:
http://sharepoint/sites/development/_api/lists/getbytitle('TestExternalList')/items
I read that you can't access External Content Types from an add-In here:
http://toddbaginski.com/blog/accessing-bcs-external-data-from-an-app-for-sharepoint-2013/
So I tried to package my BCS model as per the site and I get the following error:
The Project Item "TestBDC" cannot be deployed through a Feature in a Sandboxed Solution.
So my question is, is it possible to access an External List through an Add-In?
I am using SharePoint 2016.
Sounds like it may be a permissions issue. Do you have the BCS scope set in the app permissions?
Here's an article with info on setting up the security
https://learn.microsoft.com/en-us/sharepoint/dev/general-development/add-in-scoped-external-content-types-in-sharepoint

How to access a document library in a sharepoint online site using MS graph

I am able to access the documents on my one drive with requests like this one:
https://graph.microsoft.com/v1.0/me/drive/root/children
I am able to access a document library of a root sharepoint site of my company with a request like this:
https://graph.microsoft.com/v1.0/drive/root/children
It gives me the contents of the "root" library:
https://<my company>.sharepoint.com/Shared%20Documents
I am not able to access the document library of a SP subsite I created. e.g. this one:
https://<my company>.sharepoint.com/samplesp/Shared%20Documents
How can I access such a document library with MS Graph?
For accessing SharePoint sites and lists check out documentation of the SharePoint API in Microsoft Graph.
Update:
For those who have problems with accessing default Drive (formerly "Documents" library) on a specific SharePoint site using MS Graph API:
You should look into the documentation for accessing files on OneDrive.
As said in the question, this endpoint gives us a list of files on private OneDrive:
.../me/drive/root/children
Drive on SharePoint's sites works in the same way, but instead of me you should provide global Id of the site you want to access (global Id is <hostName>,<siteCollectionId>,<siteId>).
In conclusion: this endpoint gives us a list of files on a specified site's default drive:
.../Sharepoint/sites/<hostName>,<siteCollectionId>,<siteId>/drive/root/children
If you want to access files on a specific list, all you need is the id of the list:
.../Sharepoint/sites/<hostName>,<siteCollectionId>,<siteId>/lists/<listId>/drive/root/children
Now it should be obvious.

Resources