Unable to retrieve only folders from sharepoint rest api - sharepoint

I'm unable to restrict the sharepoint search to only retrieve folders.
I'm running rest requests to the search api
https://(sharepoint url)/ian/_api/search/query?querytext='metatest3'
This retrieves only the folder that is on this collection but when I use
https://(sharepoint url)/ian/_api/search/query?querytext='metatest3 and IsContainer:1'
This doesn't retrieve the folder and no results are found.
I'm perplexed because when the first API call is returned I have
<d:element m:type="SP.KeyValue">
<d:Key>IsContainer</d:Key>
<d:Value>true</d:Value>
<d:ValueType>Edm.Boolean</d:ValueType>
</d:element>

We can use the REST API below to search only folders.
https://(sharepoint url)/ian/_api/search/query?querytext='metatest3 contenttypeid:0x0120*'
Or
https://(sharepoint url)/ian/_api/search/query?querytext='metatest3 IsContainer:true'

Related

Correctly enter the site_ID using Graph SDK

Regarding this expression to create a folder:
POST /sites/{site-id}/drive/items/{parent-item-id}/children
What is the correct way to enter the {site-id} and the {parent-item-id}, to access a folder (eg:folder_1) in a site (eg: site1)in a domain (eg: mydomain)
I have tried:
POST /sites/mydomain/drive/items/site1/folder_1/children
POST /sites:/mydomain/site1:/drive/items/folder_1/children
and similar, with no success,
Can you help me please?
THanks for the help.
Follow your steps, but In the second step, you say:
"This is the sub folder named "2019" in default Documents library:"
With this, I can acess the shared documents folder inside the site. I don't want to acess that folder. I need to acess another folder that is in the site, but not inside the share documents folder.
Any clue?
Do a get request like this in Graph Explorer with this request:
https://graph.microsoft.com/v1.0/sites/<host>:<server relative url>
Example:
https://graph.microsoft.com/v1.0/sites/zheguo.sharepoint.com:/sites/dev
Then will return site Id
Update if you want to access other library folder in Graph, firstly get drive id with this endpoint:
https://graph.microsoft.com/v1.0/sites/{site-id}/drives
Then access the specific drive folder with this endpoint:
https://graph.microsoft.com/v1.0/sites/{site-id}/drives/{drive-id}
Then for "parent-item-id", it's the specific folder id in document library, you can get with this endpoint:
https://graph.microsoft.com/v1.0/sites/{site-id}/drives/{drive-id}/items/root:
Example:
https://graph.microsoft.com/v1.0/sites/zheguo.sharepoint.com,91a47a59-db5e-4d17-a689-479ee8905533,274459c9-4c96-42bf-9b96-838ffa387aaa/drives/b!WXqkkV7bF02miUee6JBVM8lZRCeWTL9Cm5aDj_o4eqpLdqmLE2R7QosYOZt8Dyao/items/root:/
Then use the endpoint to create folder:
POST /sites/{site-id}/drives/{drive-id}/items/{parent-item-id}/children
Example:
https://graph.microsoft.com/v1.0/sites/zheguo.sharepoint.com,91a47a59-db5e-4d17-a689-479ee8905533,274459c9-4c96-42bf-9b96-838ffa387aaa/drive/items/01WU7SPCC4FNS6KOYTSJFK2MUFRITF5XQL/children
Reference:
Create a new folder in a drive

Rest API to get the list of files inside the container/directory/ in AZURE storage

I have a container called 'services'.Inside the Container , i have a directory called 'Test'.how we can get the list of blobs inside the directory test.I have few kept few CSVs inside the test. Need the rest api to get the list of the files.
However i am able to get the list of items inside the container easily using below Rest API
https://myaccount.blob.core.windows.net/services?restype=container&comp=list
i tried
https://myaccount.blob.core.windows.net/services/Test?restype=directory&comp=list
but it is not working.
Please help to get the coorect param value or rest API to find the list of items inside the directory
https://myaccount.blob.core.windows.net/services/Test?restype=directory&comp=list&prefix=Test/
The doc:
https://learn.microsoft.com/en-us/rest/api/storageservices/list-blobs#uri-parameters
Just add a param prefix is ok.

Is there any rest end point where I can find if the id I have is a file or a folder for onedrive/sharepoint?

I have an id(fdxxxf8-6xxb-4xx0-8xx9-9xxx8) which i got from one of the API response. Is there anyway to figure it out if the id is of a file or a folder?
I need to call to different API based on if it is a folder or a file
We can use the OneDrive API like below, if the Response data contains file property, the id is of a file, if the Response data contains folder property, the id is of a folder.
/me/drive/items/{item-id}?$select=file,folder
Reference: Get a DriveItem resource

Delete files from Google drive using python through google drive api

I am trying to delete files from my google-drive using google drive apis for python.
I am able to retrieve the list of parents/children for a particular folder but when I try to delete one of the retrieved parent of the folder it gives me below error.
"https://www.googleapis.com/drive/v2/files/1j1sZ-0OAiTE9836bhTTpkUf3i4AFAvmG/parents/0AO-cNLqoD0BFUk9PVA? returned "Insufficient Permission">"
I have defined "https://www.googleapis.com/auth/drive" as my scope.
The same file got deleted when I tried "try this API" option from
developer-google.com but it does not work from my python code.
Is there anything else in the configuration that I need for deleting the files.
Thanks.

How to retrieve Sharepoint Apps from SiteContents

Iam using Sharepoint.Client library(using context - ClientContext, load & then execute) to pull metadata from SP.Web. I was able to fetch some details except the one that i required the most: "APPS". How to pull apps that installed in SP ?
There's a solution from REST API part:
https:///_api/web/webinfos?$filter=(WebTemplate eq "APP")
But I need to pull down these from my Client Library.
Here is a reference link: https://sharepoint.stackexchange.com/questions/70628/get-list-of-installed-apps-using-client-object-model
You can go through this link and it will help you to get SharePoint apps using Client Library (CSOM).
Hope this will help you.

Resources