问题
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.
回答1:
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"
}
},
回答2:
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.
来源:https://stackoverflow.com/questions/47665622/which-actions-can-i-use-to-create-a-folder-in-sharepoint-online-via-azure-logi