英文:
Getting a "Bad Request" for a GetFileByServerRelativePath/CopyTo for creating a SharePoint Page from a Template
问题
我创建了一个流程,可以根据输入到SharePoint列表的项目创建新页面。
第一步应该复制一个模板文件,并将其发布为一个新页面,使用列表项的标题名称。
我的输入如下:
{
"host": {
"connectionReferenceName": "shared_sharepointonline",
"operationId": "HttpRequest"
},
"parameters": {
"dataset": "https://myTenant.sharepoint.com/sites/KSDTestSite",
"parameters/method": "POST",
"parameters/uri": "_api/web/GetFileByServerRelativePath('/sites/KSDTestSite/SitePages/Templates/KSD-Template.aspx')/copyTo('/sites/KSDTestSite/SitePages/Microsoft_Security_Update_and_EOL_Notification.aspx')",
"parameters/headers": {
"Accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose"
}
}
}
以及输出:
{
"statusCode": 400,
"headers": {
"Pragma": "no-cache",
"Cache-Control": "no-store, no-cache",
"Set-Cookie": "ARRAffinity=fa5ce4b13622b0d3617b4398e823c470b20f49c8905d33671c1e72b454b4c01b;Path=/;HttpOnly;Secure;Domain=sharepointonline-ncus.azconn-ncus-001.p.azurewebsites.net,ARRAffinitySameSite=fa5ce4b13622b0d3617b4398e823c470b20f49c8905d33671c1e72b454b4c01b;Path=/;HttpOnly;SameSite=None;Secure;Domain=sharepointonline-ncus.azconn-ncus-001.p.azurewebsites.net",
"x-ms-request-id": "86e9b9a0-403e-3000-ac9a-13008bc3168f",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"X-Content-Type-Options": "nosniff",
"X-Frame-Options": "DENY",
"Timing-Allow-Origin": "*",
"x-ms-apihub-cached-response": "true",
"x-ms-apihub-obo": "false",
"Date": "Mon, 05 Jun 2023 16:37:17 GMT",
"Content-Length": "750",
"Content-Type": "application/json",
"Expires": "-1"
},
"body": {
"status": 400,
"message": "The expression 'web/GetFileByServerRelativePath('/sites/KSDTestSite/SitePages/Templates/KSD-Template.aspx')/copyTo('/sites/KSDTestSite/SitePages/Microsoft_Security_Update_and_EOL_Notification.aspx')' is not valid.\r\nclientRequestId: 5b37d689-d8b9-439f-af4f-2005d6b07e0d\r\nserviceRequestId: 86e9b9a0-403e-3000-ac9a-13008bc3168f",
"source": "https://myTenant.sharepoint.com/sites/KSDTestSite/_api/web/GetFileByServerRelativePath(%E2%80%98/sites/KSDTestSite/SitePages/Templates/KSD-Template.aspx%E2%80%99)/copyTo(%E2%80%98/sites/KSDTestSite/SitePages/Microsoft_Security_Update_and_EOL_Notification.aspx')",
"errors": [
"-1",
"Microsoft.SharePoint.Client.InvalidClientQueryException"
]
}
}
我不断遇到这个“Microsoft.SharePoint.Client.InvalidClientQueryException”错误,我已经看到它可能是权限问题?但这是一个开发环境,实际上没有权限可言。无论如何,如果有人有任何想法,将不胜感激。
英文:
I created a flow that would create a new page from items inputted into a SharePoint list.
The first step is supposed to copy a template file and post it as a new page using the List Item's title name.
My inputs are as follows:
{
"host": {
"connectionReferenceName": "shared_sharepointonline",
"operationId": "HttpRequest"
},
"parameters": {
"dataset": "https://myTenant.sharepoint.com/sites/KSDTestSite",
"parameters/method": "POST",
"parameters/uri": "_api/web/GetFileByServerRelativePath(‘/sites/KSDTestSite/SitePages/Templates/KSD-Template.aspx’)/copyTo(‘/sites/KSDTestSite/SitePages/Microsoft_Security_Update_and_EOL_Notification.aspx')",
"parameters/headers": {
"Accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose"
}
}
}
and the Outputs:
{
"statusCode": 400,
"headers": {
"Pragma": "no-cache",
"Cache-Control": "no-store, no-cache",
"Set-Cookie": "ARRAffinity=fa5ce4b13622b0d3617b4398e823c470b20f49c8905d33671c1e72b454b4c01b;Path=/;HttpOnly;Secure;Domain=sharepointonline-ncus.azconn-ncus-001.p.azurewebsites.net,ARRAffinitySameSite=fa5ce4b13622b0d3617b4398e823c470b20f49c8905d33671c1e72b454b4c01b;Path=/;HttpOnly;SameSite=None;Secure;Domain=sharepointonline-ncus.azconn-ncus-001.p.azurewebsites.net",
"x-ms-request-id": "86e9b9a0-403e-3000-ac9a-13008bc3168f",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"X-Content-Type-Options": "nosniff",
"X-Frame-Options": "DENY",
"Timing-Allow-Origin": "*",
"x-ms-apihub-cached-response": "true",
"x-ms-apihub-obo": "false",
"Date": "Mon, 05 Jun 2023 16:37:17 GMT",
"Content-Length": "750",
"Content-Type": "application/json",
"Expires": "-1"
},
"body": {
"status": 400,
"message": "The expression \"web/GetFileByServerRelativePath(‘/sites/KSDTestSite/SitePages/Templates/KSD-Template.aspx’)/copyTo(‘/sites/KSDTestSite/SitePages/Microsoft_Security_Update_and_EOL_Notification.aspx')\" is not valid.\r\nclientRequestId: 5b37d689-d8b9-439f-af4f-2005d6b07e0d\r\nserviceRequestId: 86e9b9a0-403e-3000-ac9a-13008bc3168f",
"source": "https://myTenant.sharepoint.com/sites/KSDTestSite/_api/web/GetFileByServerRelativePath(%E2%80%98/sites/KSDTestSite/SitePages/Templates/KSD-Template.aspx%E2%80%99)/copyTo(%E2%80%98/sites/KSDTestSite/SitePages/Microsoft_Security_Update_and_EOL_Notification.aspx')",
"errors": [
"-1",
"Microsoft.SharePoint.Client.InvalidClientQueryException"
]
}
}
I keep running into this "Microsoft.SharePoint.Client.InvalidClientQueryException" error, which I've seen it could be a permissions issue? But its a dev environment and there are really no permissions to speak of. Anyways, if anyone has any idea, it would be greatly appreciated.
答案1
得分: 0
There was an issue with quotes in the URI:
‘ was used instead of '
Correct syntax is:
{
"host": {
"connectionReferenceName": "shared_sharepointonline",
"operationId": "HttpRequest"
},
"parameters": {
"dataset": "https://your-tenant.sharepoint.com/sites/KSDTestSite",
"parameters/method": "POST",
"parameters/uri": "_api/web/GetFileByServerRelativePath('/sites/KSDTestSite/SitePages/Templates/KSD-Template.aspx')/copyTo('/sites/KSDTestSite/SitePages/Microsoft_Security_Update_and_EOL_Notification.aspx')",
"parameters/headers": {
"Accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose"
}
}
}
For security purpose, I remove your tenant root URL.
Feel free to edit your question and blur your screenshot as well.
英文:
As you find by yourself, there was an issue with quotes in the URI:
‘ was used instead of '
Correct syntax is:
{
"host": {
"connectionReferenceName": "shared_sharepointonline",
"operationId": "HttpRequest"
},
"parameters": {
"dataset": "https://your-tenant.sharepoint.com/sites/KSDTestSite",
"parameters/method": "POST",
"parameters/uri": "_api/web/GetFileByServerRelativePath('/sites/KSDTestSite/SitePages/Templates/KSD-Template.aspx')/copyTo('/sites/KSDTestSite/SitePages/Microsoft_Security_Update_and_EOL_Notification.aspx')",
"parameters/headers": {
"Accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose"
}
}
}
For security purpose, I remove your tenant root URL.
Feel free to edit your question and blur your screenshot as well.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论