MS graph API sharepoint site. Create a folder in root - sharepoint

I try to use the MS graph API to work with sharepoint sites.
All works fine, except i can not find how to create a folder in root of a site (folders are documents library).
If i know the site id (SITEID) i can list folders in root of the site as drives
GET /v1.0/sites/SITEID/drives
I have ID for each item (it is like a drive ID). The i can list folders on drives (which are subfolders of top level folders on a site)
GET /v1.0/sites/SITEID/drives/DRIVEID/root/children
I can create folders in this place and subfolders
POST /v1.0/sites/SITEID/drives/DRIVEID/root/children
{
"name": "New Folder 2",
"folder": {}
}
But how to create a top level folder on a site? In fact, how to create new drive on a site?
I try to guess something like
POST /v1.0/sites/SITEID/drives
{
"name": "New Drive",
"folder": {}
}
But this doesn't work
Also, i tried to create a list https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/list_create
POST /v1.0/sites/SITEID/lists
{
"name": "Books",
"columns": [
{
"name": "Author",
"text": { }
},
{
"name": "PageCount",
"number": { }
}
],
"list": {
"template": "documentLibrary"
}
}
no success

I think you are wrong. Folders are not document libraries.
Drive is a document library. Document library is a list with template: document library, so drive is also a list.
Endpoint
GET /v1.0/sites/SITEID/drives
will return a list of lists with template: document library.
Endpoint
GET /v1.0/sites/SITEID/lists
will return all lists of all types.
To create new drive (a document library) you should create a new list with document library as template. Then you will have a new drive in a root of the site.
What problem do you have with creation of a new list?

Related

Microsoft Graph API calls for some functionalities

I am using Sharepoint Office 365, but am new to Microsoft Graph APIs. I have 2 functionalities, namely create a folder at a specific location and upload a file at that location.
Suppose, the site url is:
'https://abcdef.sharepoint.com/sites/folder1/folder2'
So, first I have to create directory /folder1/folder2 inside sites, and then, need to upload a file (maybe text.txt) inside folder2.
I just need the subsequent Graph API calls which are needed to achieve the required functionality.
Note: I don't need any code structure, just the API calls required (in sequence).
You can follow this steps:
Create folder1.
POST https://graph.microsoft.com/v1.0/sites/{site id}/drive/root/children
{
"name": "folder1",
"folder": {},
"#microsoft.graph.conflictBehavior": "rename"
}
Create a subfolder folder2 in folder1.
POST https://graph.microsoft.com/v1.0/sites/{site id}/drive/items/{folder1 item id}/children
{
"name": "folder2",
"folder": {},
"#microsoft.graph.conflictBehavior": "rename"
}
Upload a file to folder2.
PUT https://graph.microsoft.com/v1.0/sites/{site id}/drive/items/{folder2 item id}:/file.txt:/content
Content-Type: text/plain
The contents of the file goes here.
Refer to: here

Microsoft Graph create share link for specific people

I would like to share document by link in sharepoint from microsoft graph code. Default behaviour is that every person who has link can see this file. I want to make this link working just for specific people.
So my code look like this:
Permission permission = await _graphClient.Sites[_options.SiteId]
.Drives[driveId]
.Items[itemId]
.CreateLink("view", "organization")
.Request()
.PostAsync();
This create share link for all people in organization. Now I would like to grant permissions (https://learn.microsoft.com/en-us/graph/api/permission-grant?view=graph-rest-1.0&tabs=csharp)
await graphClient.Shares["{sharedDriveItem-id}"].Permission
.Grant(roles,recipients)
.Request()
.PostAsync();
But I have no idea what should be in place "{sharedDriveItem-id}". When I put there itemId it doesn't work. Also if I put there permission.link.webUrl it also doesn't work.
What am I doing wrong?
From this documentation.
Once you create the shared link the response object returns an id, that's what you should use in place of the {sharedDriveItem-id}. See a similar response object below.
HTTP/1.1 201 Created
Content-Type: application/json
{
"id": "123ABC", // this is the sharedDriveItem-id
"roles": ["write"],
"link": {
"type": "view",
"scope": "anonymous",
"webUrl": "https://1drv.ms/A6913278E564460AA616C71B28AD6EB6",
"application": {
"id": "1234",
"displayName": "Sample Application"
},
},
"hasPassword": true
}
Okey, I found solution. There are few steps:
As sharedDriveItem-id I used encoded webUrl following by this instruction https://learn.microsoft.com/en-us/graph/api/shares-get?view=graph-rest-1.0&tabs=http
When I was creating link (https://learn.microsoft.com/en-us/graph/api/driveitem-createlink?view=graph-rest-1.0&tabs=http) in place scope i put "users"- there is no option like that in documentation but without that it doesn't work
I added Prefer in header https://learn.microsoft.com/en-us/graph/api/driveitem-createlink?view=graph-rest-1.0&tabs=http
I was using clientSecret/clientId authorization so I had to add azure app access to Sites.Manage.All and Sites.FullControl.All in Graph Api Permissions
Everything works If you using Microsoftg.Graph nuget in newest version (4.3 right now if I remember correctly)

vscode provide link to json schem via extension

I need to provide a json schema for other users without using the json schema store, for example if you look at the following link user are able to configure there own schema ,but here I want that every one who installing my vs-extension will have this jsonschema.
This is my question:
How should I link the user schema , for example for my internal usage what I did
"json.schemas": [
{
"fileMatch": [
"/*.tzr.json"
],
"url": "./tzrschema.json"
}
]
I put the schema in my workspace and link it via url and it works for me,
Assume that my vs-ext is providing a folder with file tzrschema.json , how should I link the users
workspace to the file that I’ve provided via extension ?
You should use the jsonValidation contribution point in package.json:
{
"contributes": {
"jsonValidation": [
{
"fileMatch": "/*.tzr.json",
"url": "./tzrschema.json"
}
]
}
}

Which action(s) can I use to create a folder in SharePoint Online via Azure Logic App?

As question title states, I am looking for a proper action in Logic Apps to create a folder. This action will be executed several times -- once per directory as per business rule. There will be no files created in these folders because the intent of the Logic App is to prepare a template folder structure for the users' needs.
In the official documentation I see that there are create file, create item, and list folder actions. They suggest that there might be an action to create a folder too (which I can't find).
If such action does not exist, I may need to use some SharePoint Online API, but that will be a last resort solution.
I was able to create a directory by means of SharePoint - CreateFile action. Creating a directory via a side effect of the file creation action is definitely a dirty hack (btw, inspired by a comment on MS suggestion site). This bug/feature is not documented, so relying on it in production environment is probably not a good idea.
More that that, if my problem requires creating a directory in SharePoint without any files in it whatsoever, an extra step in App Logic needs to be used. Make sure to delete the file using the Id provided by Create File action.
Here's what your JSON might look like, if you were trying to create a directory called folderCreatedAsSideEffect under preexisting TestTarget document library.
"actions": {
"Create_file": {
"inputs": {
"body": "#triggerBody()?['Name']",
"host": { "connection": { "name": "#parameters('$connections')['sharepointonline']['connectionId']" } },
"method": "post",
"path": "/datasets/#{encodeURIComponent(encodeURIComponent('https://MY.sharepoint.com/LogicApps/'))}/files",
"queries": {
"folderPath": "/TestTarget/folderCreatedAsSideEffect",
"name": "placeholder"
}
},
"runAfter": {},
"type": "ApiConnection"
},
"Delete_file": {
"inputs": {
"host": { "connection": { "name": "#parameters('$connections')['sharepointonline']['connectionId']" } },
"method": "delete",
"path": "/datasets/#{encodeURIComponent(encodeURIComponent('https://MY.sharepoint/LogicApps/'))}/files/#{encodeURIComponent(body('Create_file')?['Id'])}"
},
"runAfter": {
"Create_file": [
"Succeeded"
]
},
"type": "ApiConnection"
}
},
Correct, so far the SharePoint Connector does not support Folder management tasks.
So, your best option currently is to use the SharePoint API or client libraries in an API or Function App.

Docusign API integration - how to send multiple templates and populate values

I have a pretty basic question about how the Docusign API works. I tried finding the answer myself but was quickly overwhelmed by the massive amount of information, much of which is outdated, in the support center.
Here’s what I’m trying to do:
I have uploaded and configured multiple templates in my Docusign account
I am writing a web app which will allow my users to request a subset of those templates based on certain criteria
The subset of templates would then be used in my app via an iframe integration (I'm assuming)
I would also like to automatically populate several of the fields in my new copies of the templates
How do I perform the API request in step 2?
How do I perform the API call in step 3? Or are the values injected into the document some other way?
A totally different approach would be to provision a new Docusign account for each of my users but that didn’t seem right. If someone could just point me in there right direction I would really appreciate it.
It's actually not that basic of a question, I'd say if you were asking how to send a signature request on a document or from one template that's basic but how to combine and send multiple templates and populate values in them is a little more involved.
With that said, to combine multiple templates into signature requests you can simply use the Composite Templates node in your envelope definition. Using composite templates you can combine multiple server-side templates from your account, or combine templates with local documents or documents from other sources (i.e. cloud).
Regarding your Questions:
1]
You can make an API call to programmatically retrieve the templates that are available in your account then display whatever aspects you want about them in your UI, such as name, description, template ID, etc. Once the user (or your app logic) indicates which templates they want to combine into a signature request you can combine them like this (this combines 2 server templates):
{
"emailSubject":"DocuSign Signature Request using Composite Templates",
"status":"sent",
"compositeTemplates":[
{
"serverTemplates":[
{
"sequence":"1",
"templateId":"55A80182-2E9F-435D-9B16-FD1E1C0F9D74"
}
],
"inlineTemplates":[
{
"sequence":"1",
"recipients":{
"signers":[
{
"name":"John Doe",
"email":"firstrecipient#gmail.com",
"recipientId":"1",
"clientUserId":"1001",
"roleName":"RoleOne"
}
]
}
}
]
},
{
"serverTemplates":[
{
"sequence":"2",
"templateId":"44D9E888-3D86-4186-8EE9-7071BC87A0DA"
}
],
"inlineTemplates":[
{
"sequence":"2",
"recipients":{
"signers":[
{
"name":"Jane Doe",
"email":"secondrecipient#gmail.com",
"recipientId":"1",
"clientUserId":"1002",
"roleName":"RoleOne"
}
]
}
}
]
}
]
}
2]
Yes if you want to embed your recipients (which means they sign through your UI and not through the DocuSign website or app) then it is recommended you use an iFrame for Web apps and a Webview for mobile apps. To embed a given recipient you must set their clientUserId as I have for both recipients in the above example. This is a string and is defined on the client-side, you just need to remember which values you use for each recipient as you need that to generate each recipient's signing URL (which you will load in the iFrame).
Have a look at the "Signing from within your app" API Recipe for sample code of how to accomplish this. That sample doesn't use templates to create the envelope but it shows how to generate the unique signing URLs:
Signing from within your app
Or if you want to test with raw API calls (that don't use the DocuSign SDKs) you can use the API Explorer to test these calls:
API Explorer
3]
You basically had a third question I think which was how to populate the tabs (aka document fields) in the template. You can identify a given tab by its tabLabel and populate it's value using the value property. For instance, if you had two tabs of type textTab (called Data fields in the UI) you can populate their values like this:
{
"email": "jane.doe#email.com",
"name": "Jane Doe",
"roleName": "RoleOne",
"recipientId": "1",
"clientUserId": "1001",
"tabs": {
"textTabs": [
{
"tabLabel": "ApplicantAddress",
"value": "221 Main St. Suite 1000 San Francisco, CA 94105"
},
{
"tabLabel": "ApplicantSSN",
"value": "12-345-6789"
}
]
}
}

Resources