I'm getting a 400 error when trying to do a search both through the Graph Explorer and through my own code. Both worked a few weeks ago but have stopped working recently. Another developer has been able to replicate it in their Tenancy, but Microsoft will not provide me support as we are not a Premier Customer.
If I run this query:
https://graph.microsoft.com/v1.0/drives{drive_id}/root/
it succeeds and returns information about the drive.
Following the documentation at https://learn.microsoft.com/en-us/graph/api/driveitem-search?view=graph-rest-1.0&tabs=http a search can be used via
https://graph.microsoft.com/v1.0/drives/{drive-id}/root/search(q='foobar')
But this returns a 400 error with "One of the provided arguments is not acceptable."
However, if I search for items in our entire Tenancy via the group search it succeeds so it doesn't appear to be a permissions error, but is not a viable solution as I need to search a particular drive.
please confirm whether you are still facing the issue. I was not able to reproduce the same from my side.
I ran this query:
https://graph.microsoft.com/v1.0/me/drives/drive-id/root/Search(q='Practices Checker')
And was able to get the desired result as below:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(driveItem)",
"value": [
{
"#odata.type": "#microsoft.graph.driveItem",
"createdDateTime": "2020-12-09T11:55:47Z",
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"lastModifiedDateTime": "2020-11-03T06:51:27Z",
"name": "Practices Checker",
"webUrl": "https://microsoftapc-my.sharepoint.com/personal/ribera_xxxxxxxx_com/Documents/Documents/Practices%20Checker",
"size": 0,
"createdBy": {
"user": {
"email": "ribera#xxxxxxxxxx.com",
"displayName": "Rinki Bera"
}
},
"lastModifiedBy": {
"user": {
"email": "ribera#xxxxxxxxxx.com",
"displayName": "Rinki Bera"
}
},
...
]
}
Thank you.
Related
I'm a newbie with Azure DevOps API, and for a future migration case, I want to create new users on my Azure DevOps organization. The users is Azure Active Directory users.
So I tried to do it with that documentation : https://learn.microsoft.com/en-us/rest/api/azure/devops/graph/users/create?view=azure-devops-rest-6.0
The body of my API request look like this:
{
"principalName": "test_user#company.com"
}
It return a status 201 (created) with this informations (for security reason i've put '.' on some lines):
{
"subjectKind": "user",
"metaType": "member",
"directoryAlias": "test_user",
"domain": "....",
"principalName": "test_user#company.com",
"mailAddress": "test_user#company.com",
"origin": "aad",
"originId": "....",
"displayName": "test user",
"_links": {
"self": {
"href": "....."
},
"memberships": {
"href": "....."
},
"membershipState": {
"href": "...."
},
"storageKey": {
"href": "...."
},
"avatar": {
"href": "...."
}
},
"url": "....",
"descriptor": "....."
}
But when I look on the organization users, I don't see any users who was created.
Did I miss something ? When I list users thourgh API it don't appear either...
Thanks in advance for your help.
P.S: It work well in the graphic UI.
Ok, I've finaly solve my own problem...
The parameter groupDescriptors is mandatory in the HTTP request in order to activate the account.
The command should look like that:
https://vssps.dev.azure.com/{{COMPANY}}/_apis/graph/users?groupDescriptors=vssgp.{{GROUPDESCRIPTORS}}&api-version=6.0-preview.1
If you don't add the user to a group when you do the creation, he will not be able to connect.
Get the group descriptor:
https://vssps.dev.azure.com/{{COMPANY}}/_apis/graph/groups?api-version=5.1-preview.1
Hope this will help someone else in the internet.
I am trying to figure out how to obtain an "item-id" for a file in a sharepoint site for microsoft graph API.
Microsoft documentation: https://learn.microsoft.com/en-us/graph/api/driveitem-get?view=graph-rest-1.0&tabs=http
Here is what I tried for far:
Tried using https://developer.microsoft.com/en-us/graph/graph-explorer to guess the api link that will let me download the file I want.
I first tried to get the sharepointsite like so:
https://graph.microsoft.com/v1.0/sites/omidtechnfr.sharepoint.com:/sites/delploy
That worked:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites/$entity",
"createdDateTime": "2021-07-15T21:02:02.78Z",
"description": "delploy",
"id": "omidtechnfr.sharepoint.com,5e03397e-03b0-4d92-9658-f9163f0131b3,1d9f21da-4d74-45db-b5d4-e4a7f7f278a1",
"lastModifiedDateTime": "2021-07-17T02:16:39Z",
"name": "delploy",
"webUrl": "https://omidtechnfr.sharepoint.com/sites/delploy",
"displayName": "delploy",
"root": {},
"siteCollection": {
"hostname": "omidtechnfr.sharepoint.com"
}
}
So then I tried using what I ASSUME is the item-id for the SharePoint site delploy to try and get more information out of the site so I can try to find the item-id for the file I want to download:
https://graph.microsoft.com/v1.0/sites/5e03397e-03b0-4d92-9658-f9163f0131b3/drive/
And I got back some result but it doesn't so the item-id for me to do anything with it:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives/$entity",
"createdDateTime": "2021-07-11T05:16:50Z",
"description": "",
"id": "b!fjkDXrADkk2WWPkWPwExs9ohnx10TdtFtdTkp_fyeKF_K1_Z49FFSbzXVFRA5GKa",
"lastModifiedDateTime": "2021-07-16T18:32:35Z",
"name": "Documents",
"webUrl": "https://omidtechnfr.sharepoint.com/sites/delploy/Shared%20Documents",
"driveType": "documentLibrary",
"createdBy": {
"user": {
"displayName": "System Account"
}
}
At this point I started to get desperate and a little angry. So I tried to just download the file from sharepoint and assume that the characters at the end of the download link was the item-id but that didn't work either:
download link:
https://omidtechnfr.sharepoint.com/sites/delploy/_layouts/15/download.aspx?UniqueId=25e2fd4f%2Deb32%2D43ac%2D9141%2Dfa47a610a27c
Used https://www.urldecoder.org/ to decode what I am assuming is the item-id for the file I want to download
25e2fd4f-eb32-43ac-9141-fa47a610a27c
Then tried to desperately tack this on to the Microsoft graph api to see what happens:
https://graph.microsoft.com/v1.0/sites/5e03397e-03b0-4d92-9658-f9163f0131b3/drive/items/25e2fd4f-eb32-43ac-9141-fa47a610a27c
and it failed:
{
"error": {
"code": "itemNotFound",
"message": "The resource could not be found.",
"innerError": {
"date": "2021-07-17T14:13:51",
"request-id": "985e2893-5343-47ac-a93c-6629a00c4eb3",
"client-request-id": "73a3b6d0-f1ce-bb51-b126-43f0957d15e3"
}
}
}
You could get the file by the path: https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/{item-path}
For example: https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/test.docx
If the file is in a folder, it would be like this: https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/folder1/test.docx
I used the search site id endpoint GET /sites/{site-id}/drive/root/search(q='{search-text}')
Documentation here.
So I am not sure where I am going wrong but here goes!
I want to list files on my test Sharepoint site via the MS GraphAPI. This via the documentation should be simple but it's just not happening!
I am using the GraphAPI explorer
https://developer.microsoft.com/en-us/graph/graph-explorer/preview
I then can see my site and its shared folder via this call
https://graph.microsoft.com/v1.0/sites/MyCompany.sharepoint.com:/sites/burf-test:/drive
I get back:
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives/$entity",
"createdDateTime": "2020-04-19T05:47:58Z",
"description": "",
"id": "b!BWveRisE5UWH2b_vq03PZYmZdMdKpQtFhpIQSacsCowq3ZxYLFsFQKtzuZ4-V1ya",
"lastModifiedDateTime": "2020-04-30T13:50:28Z",
"name": "Documents",
"webUrl": "https://-.sharepoint.com/sites/Burf-Test/Shared%20Documents",
"driveType": "documentLibrary",
"createdBy": {
"user": {
"displayName": "System Account"
}
},
"owner": {
"group": {
"email": "Burf-Test#-.onmicrosoft.com",
"id": "e48afefa-2aa8-4cd5-aad9-62f746a991c2",
"displayName": "Burf-Test Owners"
}
},
"quota": {
"deleted": 0,
"remaining": 0,
"total": 0,
"used": 0
}
}
I can not find a way to list the files that I can see via my Sharepoint portal (Burf-Test)?
Tried
/drive/root/children
/drive/b!BWveRisE5UWH2b_vq03PZYmZdMdKpQtFhpIQSacsCowq3ZxYLFsFQKtzuZ4-V1ya
/drives/b!BWveRisE5UWH2b_vq03PZYmZdMdKpQtFhpIQSacsCowq3ZxYLFsFQKtzuZ4-V1ya
/drive/Documents
/lists etc
and a whole lot more!
So the main issue here was actually permissions, sometimes the Graph Explorer will say Access denied, and sometimes it will return a 200 but not show the files. Both mean a permissions issue.
I found I had to grant extra permissions (File ones) to get this to work
https://graph.microsoft.com/v1.0/sites/a-.sharepoint.com,SITE-GUID/drives/FOLDER-GUID/root/children
How to get the Microsoft SharePoint SiteID using Microsoft Graph API Explorer.
Initially i tried with below API i able to get the Site ID
https://graph.microsoft.com/v1.0/sites/tenantName.sharepoint.com:/sites/TestSite:/drives?select=name,id
Sharepoint URL:
https://tenantName.sharepoint.com/sites/TestSite
I output i got is:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives",
"value": [
{
"id": "b!l17-JY9YT67Qp-2TBvsUupBLMUF2SrJHp5VylCDZThT7HpCdF-7uQ6NTp6t-MbR5",
"name": "Documents"
}
]
}
But, when i try with Communication Site
Whose SharePoint URL is:
https://tenantName.sharepoint.com/SitePages/DevHome.aspx
Graph Explorer API
https://graph.microsoft.com/v1.0/sites/tenantName.sharepoint.com:/SitePages/DevHome:/drives?select=name,id
I am getting below error:
{
"error": {
"code": "itemNotFound",
"message": "The provided path does not exist, or does not represent a site",
"innerError": {
"request-id": "8329dfca-c63b-4af5-80b8-75f26be9e2e8",
"date": "2019-10-31T13:18:33"
}
}
}
A sitePage is a fundamentally different resource than a site.
A site is a container that owns any number of sub-sites, apps, lists, document libraries, etc.
A sitePage is just another resource owned by a site.
The sitePage resource is currently only available in the Microsoft Graph Beta version.
So the query for /SitePages/DevHome.aspx would be:
/beta/sites/root/pages/{pageId}
If you don't yet know the correct id for the page, you can filter the SitePage collection based on the page's name:
/beta/sites/root/pages?$filter=name eq 'DevHome.aspx'
This will return a collection with a single entity (the DevHome.aspx page):
{
"#odata.context": "https://graph.microsoft.com/beta/$metadata#sites('root')/pages",
"value": [
{
"eTag": "",
"id": "{id}",
"lastModifiedDateTime": "2014-07-10T05:47:29Z",
"name": "DevHome.aspx",
"webUrl": "SitePages/DevHome.aspx",
"createdBy": {
"user": {
"displayName": "System Account"
}
},
"lastModifiedBy": {
"user": {
"displayName": "System Account"
}
},
"parentReference": {
"siteId": "{id}"
},
"contentType": {
"id": "0x0101080062C83F3CFED6744A882F729480DE6C17",
"name": "Wiki Page"
},
"webParts": [],
"publishingState": {
"level": "published",
"versionId": "1.0"
}
}
]
}
I should also point out that you're misinterpreting the result of your first query. When you request /v1.0/sites/{tenant}:/{path}:/drives?select=name,id, you are not getting the IDs for each Site, you're getting the IDs for each Drive within that Site. You can find the objects contained within a site in the Relationships section of the Site Resource documentation
Your Graph API call is incorrect.
Try this one :
https://graph.microsoft.com/v1.0/sites/tenantName.sharepoint.com?select=name,id
I need all root sites listed in share point Admin center shown in image
For that i am using Graph api like follows,
var settings = {
"async": true,
"crossDomain": true,
"url": "https://graph.microsoft.com/beta/sharepoint/sites",
"method": "GET",
"headers": {
"authorization": "Bearer token",
"cache-control": "no-cache",
"postman-token": "3116b007-e574-5ad4-aedd-3b35fbf76b61"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
But it gives output as follows,
{
"#odata.context": "https://graph.microsoft.com/beta/$metadata#sharePoint/sites",
"value": [
{
"createdDateTime": "2017-02-18T13:03:01.263Z",
"description": "",
"id": "2422c3a2-3c51-40f1-8483-5454aead43c4,412bb897-c754-460a-962d-db22893a1649",
"lastModifiedDateTime": "2017-04-24T02:16:43Z",
"name": "",
"webUrl": "https://mps330124.sharepoint.com",
"root": {},
"siteCollection": {
"hostname": "mps330124.sharepoint.com"
},
"siteCollectionId": "2422c3a2-3c51-40f1-8483-5454aead43c4",
"siteId": "412bb897-c754-460a-962d-db22893a1649"
}
]
}
How can i achieve it Using graph api beta
Using the asterisk on the site search endpoint seems to work
https://graph.microsoft.com/v1.0/sites?search=*
returns
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites",
"value": [
{
"createdDateTime": "2017-09-15T01:11:50Z",
"description": "Let's capture our thoughts in this subsite blog.",
"id": "xyz.sharepoint.com,5a58bb09-1fba-41c1-8125-69da264370a0,5e9767b8-95bc-4bd1-aeb0-defabcdefabc",
"lastModifiedDateTime": "0001-01-01T08:00:00Z",
"name": "internalblogs",
"webUrl": "https://xyz.sharepoint.com/internalblogs",
"displayName": "Internal blog"
},
{
...
}]
}
There isn't a way to retrieve a full list of site collections via Microsoft Graph. That functionality is "admin only" in the SharePoint API and has not been made available via Microsoft Graph.
We're working on some changes to the SharePoint Sites API for Microsoft Graph that will be rolled out over the next few weeks to make it possible to search for a list of sites / site collections, but we still don't have plans to make available the ability to enumerate all sites / site collections via Microsoft Graph.
Watch the Change Log around the Build 2017 conference (May 10-12) to find our all the details.
There now seems to be a way to get a list of the top level site collections via the following request:
GET https://graph.microsoft.com/beta/sites?select=siteCollection,webUrl&filter=siteCollection/root%20ne%20null
The following page documents this (update September 19th): https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/site_list
My own test though didn't bear any fruit, because the API returns a Cannot enumerate sites error. An alternative approach would be to use the search query parameter (docs updated September 20th):
GET https://graph.microsoft.com/beta/sites?search=contoso&select=siteCollection,WebUrl&filter=siteCollection/root ne null
But this only provides the siteCollection for the root :/ with a list of all sites and their webUrl of the other siteCollection's (like the default ones /sites & /teams) but not the actual url/hostname of the siteCollection they belong to. Though that could be extracted from the webUrl path component.
What you are getting is not an error.
If you follow the siteCollectionId with the URL https://graph.microsoft.com/beta/sharepoint/sites/2422c3a2-3c51-40f1-8483-5454aead43c4/sites you get a list of the sites in that site collection.