从Azure逻辑应用中如何设置在Flow中创建的SharePoint文件的标题。

huangapple go评论53阅读模式
英文:

from azure logic app how to set title of a file in sharepoint that was created in flow

问题

我想使用Azure逻辑应用在SharePoint中创建一个带标题的文件。然而,SharePoint的“创建文件”操作没有提供设置文件标题的字段(如下图1所示,没有添加新参数的选项)。

从Azure逻辑应用中如何设置在Flow中创建的SharePoint文件的标题。

经过研究,我发现“更新文件属性”操作允许输入文件标题。然而,这个操作需要文件ID(如下图2所示),而SharePoint会自动生成,我无法获取。

从Azure逻辑应用中如何设置在Flow中创建的SharePoint文件的标题。

我向chatgbt寻求帮助,他们建议获取文件属性,然后搜索文件ID。然而,这种方法会生成查询“Name eq test.png”时的错误消息“列名称不存在”。Chatgbt提供的所有解决方法似乎越来越复杂,都无法正常工作。

从Azure逻辑应用中如何设置在Flow中创建的SharePoint文件的标题。

我该如何在SharePoint中的流程中为新创建的文件设置文件标题?提前谢谢!

英文:

I would like to create a file with a title in SharePoint using an Azure Logic App. However, the 'create file' action for SharePoint does not provide a field to set the file title (and there is no option to add a new parameter, as seen in pic 1 below).

从Azure逻辑应用中如何设置在Flow中创建的SharePoint文件的标题。

Upon researching, I discovered that the 'update file properties' action allows entry of a file title. However, this operation requires the file ID (as seen in pic 2 below), which SharePoint creates and I don't have.

从Azure逻辑应用中如何设置在Flow中创建的SharePoint文件的标题。

I asked chatgbt for help, and they suggested getting the file properties, then searching for the file ID. However, this approach generates the error "column Name doesn't exist" for the query Name eq test.png. All workarounds suggested by chatgbt appear to be increasingly complicated and are not working.

从Azure逻辑应用中如何设置在Flow中创建的SharePoint文件的标题。

How can I set the file title for a file I just created in my flow in SharePoint? Thank you in advance!

答案1

得分: 1

这个操作需要文件ID(如下图所示),SharePoint会自动生成,我没有。

我在我的环境中重现并获得了如下所示的预期结果:

设计:

从Azure逻辑应用中如何设置在Flow中创建的SharePoint文件的标题。

你会得到前面步骤的ID,就像我得到的一样。

代码视图:


{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Create_file": {
                "inputs": {
                    "body": "@triggerBody()",
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['sharepointonline']['connectionId']"
                        }
                    },
                    "method": "post",
                    "path": "/datasets/@{encodeURIComponent(encodeURIComponent('https://microsoftapc.sharepoint.com/teams/StackOverflowSupport'))}/files",
                    "queries": {
                        "folderPath": "/Shared Documents/TEST1",
                        "name": "EmoRA",
                        "queryParametersSingleEncoded": true
                    }
                },
                "runAfter": {},
                "runtimeConfiguration": {
                    "contentTransfer": {
                        "transferMode": "Chunked"
                    }
                },
                "type": "ApiConnection"
            },
            "Update_file_properties": {
                "inputs": {
                    "body": {
                        "Title": "Testing Rithwik"
                    },
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['sharepointonline']['connectionId']"
                        }
                    },
                    "method": "patch",
                    "path": "/datasets/@{encodeURIComponent(encodeURIComponent('https://microsoftapc.sharepoint.com/teams/StackOverflowSupport'))}/tables/@{encodeURIComponent(encodeURIComponent('428d88e4-22a3-4ab1-9cc7-0abd79c95be9'))}/items/@{encodeURIComponent(body('Create_file')['ItemId'])}/patchfileitem"
                },
                "runAfter": {
                    "Create_file": [
                        "Succeeded"
                    ]
                },
                "type": "ApiConnection"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "manual": {
                "inputs": {
                    "schema": {}
                },
                "kind": "Http",
                "type": "Request"
            }
        }
    },
    "parameters": {
        "$connections": {
            "value": {
                "sharepointonline": {
                    "connectionId": "/subscriptions/b83c/resourceGroups/bojja/providers/Microsoft.Web/connections/sharepointonline",
                    "connectionName": "sharepointonline",
                    "id": "/subscriptions/b83/providers/Microsoft.Web/locations/eastus/managedApis/sharepointonline"
                }
            }
        }
    }
}

输出:

从Azure逻辑应用中如何设置在Flow中创建的SharePoint文件的标题。

从Azure逻辑应用中如何设置在Flow中创建的SharePoint文件的标题。

所以,在创建文件后,你会得到ItemId,可以用来更新文件的标题,就像我所做的一样。

英文:

>this operation requires the file ID (as seen in pic 2 below), which SharePoint creates and I don't have.

I have reproduced in my environment and got expected results as below:

Design:

从Azure逻辑应用中如何设置在Flow中创建的SharePoint文件的标题。

You will get id previous steps as i have got.

Code view:


{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Create_file": {
                "inputs": {
                    "body": "@triggerBody()",
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['sharepointonline']['connectionId']"
                        }
                    },
                    "method": "post",
                    "path": "/datasets/@{encodeURIComponent(encodeURIComponent('https://microsoftapc.sharepoint.com/teams/StackOverflowSupport'))}/files",
                    "queries": {
                        "folderPath": "/Shared Documents/TEST1",
                        "name": "EmoRA",
                        "queryParametersSingleEncoded": true
                    }
                },
                "runAfter": {},
                "runtimeConfiguration": {
                    "contentTransfer": {
                        "transferMode": "Chunked"
                    }
                },
                "type": "ApiConnection"
            },
            "Update_file_properties": {
                "inputs": {
                    "body": {
                        "Title": "Testing Rithwik"
                    },
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['sharepointonline']['connectionId']"
                        }
                    },
                    "method": "patch",
                    "path": "/datasets/@{encodeURIComponent(encodeURIComponent('https://microsoftapc.sharepoint.com/teams/StackOverflowSupport'))}/tables/@{encodeURIComponent(encodeURIComponent('428d88e4-22a3-4ab1-9cc7-0abd79c95be9'))}/items/@{encodeURIComponent(body('Create_file')?['ItemId'])}/patchfileitem"
                },
                "runAfter": {
                    "Create_file": [
                        "Succeeded"
                    ]
                },
                "type": "ApiConnection"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "manual": {
                "inputs": {
                    "schema": {}
                },
                "kind": "Http",
                "type": "Request"
            }
        }
    },
    "parameters": {
        "$connections": {
            "value": {
                "sharepointonline": {
                    "connectionId": "/subscriptions/b83c/resourceGroups/bojja/providers/Microsoft.Web/connections/sharepointonline",
                    "connectionName": "sharepointonline",
                    "id": "/subscriptions/b83/providers/Microsoft.Web/locations/eastus/managedApis/sharepointonline"
                }
            }
        }
    }
}

Output:

从Azure逻辑应用中如何设置在Flow中创建的SharePoint文件的标题。

从Azure逻辑应用中如何设置在Flow中创建的SharePoint文件的标题。

So after creating a file you get ItemId which can be used to updating the files title as I have done.

huangapple
  • 本文由 发表于 2023年6月19日 16:13:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/76504795.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定